How to read an Engauge CSV file with multiple separate tables into a list of Pandas Series
This How-To shows how to read a CSV-file with multiple tables separated by a new line (as generated by
) into a list of ‘
import pandas as pd
import numpy as np
"""Reads a CSV file with multiple arrays stored by Engauge.
Returns a list of series with names, x and y given by Engauge curves."""
with open (fileName, "r") as dataFile:
dataStrings = dataFile.read()
dataStrings = dataStrings.replace('\n\n', "BREAK")
dataStrings = dataStrings.replace('\n',',')
dataStrings = dataStrings.split("BREAK")
# Remove the "," put by Engauge at the end of the last line.
dataStrings[-1] = dataStrings[-1].rstrip(',')
dataSeries = 
for dataString in dataStrings:
dataList = dataString.split(",")
dataName = dataList
data = np.array(dataList[2:])
data = data.astype(np.float64)
data = data.reshape(-1,2) # Reshape to pairs