1

Topic: [Python] As such file?

Hello! There is a file with such approximately contents: ID, Text 0 || text0 1 || text1 2 || text2 Accordingly, a question - as ? It would be desirable to receive, probably, DataFrame pandas with two columns in the total (if probably). I will be grateful for the help.

2

Re: [Python] As such file?

Hello, sun2013, you wrote: S> Hello! S> there is a file with such approximately contents: S> ID, Text S> 0 || text0 S> 1 || text1 S> 2 || text2 S> Accordingly, a question - as ? It would be desirable to receive, probably, DataFrame pandas with two columns in the total (if probably). I will be grateful for the help. https://docs.python.org/2/library/csv.html... <<RSDN@Home 1.0.0 alpha 5 rev. 0>>

3

Re: [Python] As such file?

Hello, sun2013, you wrote: S> Hello! S> there is a file with such approximately contents: S> ID, Text S> 0 || text0 S> 1 || text1 S> 2 || text2 S> Accordingly, a question - as ? It would be desirable to receive, probably, DataFrame pandas with two columns in the total (if probably). I will be grateful for the help. df = pandas.read_csv (' myfile.txt ', delimiter = ' \| \| ', engine ='python ', skiprows=1, header=None) df.columns = [' ID ', ' Text '] 1. Since the separator "||" has length two characters (instead of one, as usual), it was necessary to specify engine=python 2. Since the separator of titles of columns differs from a row terminator it was necessary to disconnect generally parsing of titles (skiprows=1, header=None). And then to register titles it is explicit.