Im developing an API which should, ideally, export a conmma-separated list as a .txt file which should look like
alphanumeric1, alphanumeric2, alphanumeric3
the data to be exported is coming from a column of a pandas dataframe, so I guess I get it, but all my attempts to get it as a single-line string literal havent worked. Instead, the text file I receive is
JavaScript
x
5
1
,ColumnHeader
2
0,alphanumeric1
3
0,alphanumeric2
4
0,alphanumeric3
5
I’ve tried using string literals with the backticks, writing to multiple lines, appending commas to each value in the list, but it all comes out in the form of a csv, which wont work for my purposes.
How would yall achieve this effect?
Advertisement
Answer
I am not sure if what you need is:
JavaScript
1
2
1
csvList = ','.join(df.ColumnHeader)
2
where, df is of course your pandas dataframe