csv-import

Attaching new lines to existing excel in python with data from multiple csvs

Attaching new lines to existing excel in python with data from multiple csvs Question: I’m trying to read out data from multiple csv files in a folder, selecting specific column, adding the file name as an additional column and finally writing this to an existing excel. The print output does what I’d like to do, …

Total answers: 1

Create Pandas DataFrame from a string

Create Pandas DataFrame from a string Question: In order to test some functionality I would like to create a DataFrame from a string. Let’s say my test data looks like: TESTDATA=”””col1;col2;col3 1;4.4;99 2;4.5;200 3;4.7;65 4;3.2;140 “”” What is the simplest way to read that data into a Pandas DataFrame? Asked By: Emil L || Source …

Total answers: 7

pandas read_csv and filter columns with usecols

pandas read_csv and filter columns with usecols Question: I have a csv file which isn’t coming in correctly with pandas.read_csv when I filter the columns with usecols and use multiple indexes. import pandas as pd csv = r”””dummy,date,loc,x bar,20090101,a,1 bar,20090102,a,3 bar,20090103,a,5 bar,20090101,b,1 bar,20090102,b,3 bar,20090103,b,5″”” f = open(‘foo.csv’, ‘w’) f.write(csv) f.close() df1 = pd.read_csv(‘foo.csv’, header=0, names=[“dummy”, …

Total answers: 5