brightwind.load.load.load_csv¶
-
brightwind.load.load.
load_csv
(filepath_or_folder, search_by_file_type=['.csv'], print_progress=True, **kwargs)¶ Load timeseries data from a csv file, or group of files in a folder, into a DataFrame. The format of the csv file should be column headings in the first row with the timestamp column as the first column, however these can be over written by sending your own arguments as this is a wrapper around the pandas.read_csv function. The pandas.read_csv documentation can be found at: https://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html
- Parameters
filepath_or_folder (str) – Location of the file folder containing the timeseries data.
search_by_file_type (List[str], default ['.csv']) – Is a list of file extensions to search for e.g. [‘.csv’, ‘.txt’] if a folder is sent.
print_progress (bool, default True) – If you want to print out statements of the file been processed set to True. Default is True.
kwargs – All the kwargs from pandas.read_csv can be passed to this function.
- Returns
A DataFrame with timestamps as it’s index.
- Return type
pandas.DataFrame
When assembling files from folders into a single DataFrame with timestamp as the index it automatically checks for duplicates and throws an error if any found.
Example usage
import brightwind as bw filepath = r'C:\some\folder\some_data2.csv' df = bw.load_csv(filepath) print(df)
To load a group of files from a folder other than a .csv file type:
folder = r'C:\some\folder\with\txt\files' df = bw.load_csv(folder, search_by_file_type=['.txt'], print_progress=True)
If you want to load something that is different from a standard file where the column headings are not in the first row, the pandas.read_csv key word arguments (kwargs) can be used:
filepath = r'C:\some\folder\some_data_with_column_headings_on_second_line.csv' df = bw.load_csv(filepath, skiprows=0)