Loads data from a CSV file into a specified table in the Ladybug database.
Arguments
- conn
A Ladybug connection object.
- file_path
A string specifying the path to the CSV file.
- table_name
A string specifying the name of the destination table in Ladybug.
- optional_csv_parameter
An optional parameter for CSV-specific configurations (e.g., delimiter, header). Refer to Ladybug documentation for available options.
Examples
# \donttest{
conn <- lb_connection(":memory:")
#> Error in py_run_string_impl(code, local, convert): AttributeError: 'NoneType' object has no attribute 'Database'
#> Run `reticulate::py_last_error()` for details.
lb_execute(conn, "CREATE NODE TABLE City(name STRING, population INT64,
PRIMARY KEY (name))")
#> Error: object 'conn' not found
# Create a temporary CSV file
csv_file <- tempfile(fileext = ".csv")
write.csv(data.frame(name = c("Berlin", "London"),
population = c(3645000, 8982000)),
csv_file, row.names = FALSE)
# Load data from CSV
lb_copy_from_csv(conn, csv_file, "City")
#> Error: object 'conn' not found
# Verify the data
result <- lb_execute(conn, "MATCH (c:City) RETURN c.name, c.population")
#> Error: object 'conn' not found
print(as.data.frame(result))
#> Error: object 'result' not found
# Clean up the temporary file
unlink(csv_file)
# }
