CSV

This functionality is in Beta! Beta functionality may have bugs and may change in the future. Help us out by testing this functionality and letting us know if you encounter any issues.

CSVHandler

Use this object to create a handler for reading and writing local CSV files.

from sdv.io.local import CSVHandler

connector = CSVHandler()

Parameters

  • sep: The character used to separate the different data values

    • (default) ',': A comma use used to separate the values

  • encoding: The character encoding used

Output A CSVHandler object you can use to read and write CSV files

read

Use this function to read multiple CSV files form your local machine

data = connector.read(folder_name='project/data/')

Parameters

  • (required) folder_name: A string name of the folder that contains your CSV files

Output A dictionary that contains all the CSV data found in the folder. The key is the name of the file (without the .csv suffix) and the value is a pandas DataFrame containing the data.

write

Use this function to write synthetic data as multiple CSV files

connector.write(
  synthetic_data,
  folder_name='project/synthetic_data',
  file_name_suffix='_v1', 
  mode='x')
)

Parameters

  • (required) synthetic_data: You data, represented as a dictionary. The key is the name of each table and the value is a pandas DataFrame containing the data.

  • (required) folder_name: A string name of the folder where you would like to write the synthetic data

  • file_name_suffix: The suffix to add to each filename. Use this if to add specific version numbers or other info.

    • (default) None: Do not add a suffix. The file name will be the same as the table name with a .csv extension

    • <string>: Append the suffix after the table name. Eg. a suffix '_synth1' will write a file as table_synth1.csv

  • mode: A string signaling which mode of writing to use

    • (default) 'x': Write to new files, raising errors if any existing files exist with the same name

    • 'w': Write to new files, clearing any existing files that exist

    • 'a': Append the new CSV rows to any existing files

Output (None) The data will be written as CSV files

Last updated

Copyright (c) 2023, DataCebo, Inc.