with open(file, 'w') as f:
can write csv files directly (though file
is CLAIMED to be String
only)
1 | # better: dataframe -> csv; then read: csv -> dataframe |
with open
writes csv:1
2
3
4
5
6
7
8
9
10
11,full_name
0,Aaron Mitchell
1,Alexandre Rocha
2,Astrid Gruber
3,Bjørn Hansen
4,Camille Bernard
5,Daan Peeters
6,Dan Miller
7,Diego Gutiérrez
8,Dominique Lefebvre
9,Eduardo Martinswith open
writes string:1
2
3
4
5
6
7
8
9
10
11full_name
0 Aaron Mitchell
1 Alexandre Rocha
2 Astrid Gruber
3 Bjørn Hansen
4 Camille Bernard
5 Daan Peeters
6 Dan Miller
7 Diego Gutiérrez
8 Dominique Lefebvre
9 Eduardo Martins
When reading to dataframe, it would be quite easy to deal with csv files while this is not the case with string files. Note that the files would be in extension .csv
.
In that case, why bother using io.StringIO()
to transform dataframe into a string then csv? Reverting back would be arduous.
1 | def read_expected_csv(self, query_func): |