DiFfRG.file_io.csv#

Functions#

read_csv(csv[, delim, header])

Reads a csv file and returns a pandas dataframe.

read_k_csv(filename[, delim, kName])

Reads a csv file which contains data for different values of k and returns the data split into separate csvs for each value of k.

split_csv(csv[, name])

Reads a csv file which contains data for different values of k and returns the data split into separate csvs for each value of k.

Module Contents#

DiFfRG.file_io.csv.read_csv(csv, delim=',', header='infer')#

Reads a csv file and returns a pandas dataframe.

Follows the same dialect as the C++ reader in DiFfRG/common/csv.hh and the Julia reader in julia/src/io/csv.jl: “#” comment lines and blank lines are skipped, cells that are not finite numbers read back as NaN, and rows whose field count does not match the header are skipped.

Parameters:
  • csv (str) – The path to the csv file.

  • delim (str, optional) – Delimiter used in the csv file. Defaults to “,”.

  • header (str, optional) – Header argument for pandas. Use None if no header exists. Defaults to “infer”.

Returns:

The data in the csv file.

Return type:

pandas.DataFrame

DiFfRG.file_io.csv.read_k_csv(filename, delim=',', kName='kGeV')#

Reads a csv file which contains data for different values of k and returns the data split into separate csvs for each value of k.

Parameters:
  • filename (str) – The path to the csv file.

  • delim (str, optional) – Delimiter used in the csv file. Defaults to “,”.

  • kName (str, optional) – The name of the column which contains the values of k. Defaults to “kGeV”.

Returns:

A tuple containing a list with the unique values of k and a list of pandas dataframes for each value of k.

Return type:

tuple

DiFfRG.file_io.csv.split_csv(csv, name='kGeV')#

Reads a csv file which contains data for different values of k and returns the data split into separate csvs for each value of k.

Parameters:
  • filename (str) – The path to the csv file.

  • delim (str, optional) – Delimiter used in the csv file. Defaults to “,”.

  • kName (str, optional) – The name of the column which contains the values of k. Defaults to “kGeV”.

Returns:

A tuple containing a list with the unique values of k and a list of pandas dataframes for each value of k.

Return type:

tuple