0

I have a list containing some text data.

When I used pd.DataFrame to put in the list I cannot see the whole data.

traffic = 'filename' 
traffic_data = open(traffic, 'r')
first_line = traffic_data.readlines()
data = pd.DataFrame(first_line)
data.iloc[64968]

The result is: "0 120 ddhg-bjh bjh-de de-ddgc ddgc-cjdh cjdh-ddc..."

When I print the original element:

first_line[64968]

The result is : '120 ddhg-bjh bjh-de de-ddgc ddgc-cjdh cjdh-ddc ddc-c c-hf hf-gid gid-cjah cjah-cicd cicd-hcj hcj-egea egea-dec dec-gdcf gdcf-bhdh bhdh-gecg gecg-egab egab-cdgh cdgh-cg cg-iff iff-hheg hheg-bggd bggd-fgg fgg-bhia bhia-bbi bbi-dhgh dhgh-fgad fgad-i i-ccj ccj-hhig hhig-d d-f f-cffg cffg-bc bc-bhhb bhhb-eddf eddf-ee ee-bfbd bfbd-fjig fjig-gij gij-bdi bdi-badi badi-ddai ddai-ddfh ddfh-gafd gafd-a a-eb eb-ehcf ehcf-eaei eaei-egie egie-bdf bdf-hbd hbd-fcjd fcjd-daah daah-dde dde-fai fai-feh feh-dacc dacc-eheh eheh-gd gd-fgi fgi-cfg cfg-dfae dfae-decb decb-ecbf ecbf-efae efae-baa baa-gch gch-gaia gaia-bbfi bbfi-bdhh bdhh-ccc ccc-edgc edgc-ejii ejii-h h-ccgi ccgi-eeeb eeeb-cb cb-bgh bgh-eabc eabc-bede bede-idc idc-bhf bhf-dcfg dcfg-egbe egbe-bbbd bbbd-ea ea-ddb ddb-ebid ebid-ffeh ffeh-bh bh-dhcj dhcj-jda jda-efah efah-ebfi ebfi-begf begf-hghb hghb-ejcb ejcb-cfhi cfhi-hddf hddf-dhi dhi-fbih fbih-cecd cecd-ihi ihi-gbab gbab-hab hab-gchd gchd-bghi bghi-hejf hejf-fhbi fhbi-eejb eejb-ejdg ejdg-fd fd-ddi ddi-dbag dbag-gfje gfje-iea iea-efgb efgb-jdb jdb-hcdd\n'

I need help to understand why it is happening and what can be done to read file in pandas as these text will be broken into 10 further category and then into dataframe with 10 columns.

I understand the question might be silly for experienced users but as a new user I am not able to find the answer anywhere else.

Thanks for your help.

  • try reading it directly into pandas, no need for the additional `I/O` pandas handles that for you `pd.read_csv('filename.csv',sep=',')` – Umar.H Mar 03 '21 at 12:41

1 Answers1

0

Have a look at:

Pretty-print an entire Pandas Series / DataFrame

Pandas doesn't print long lines and cuts of the line after some symbols. Most of the time, this is not a problem, except you have entries with huge sizes.

2er0
  • 361
  • 2
  • 11
  • Thank you for the link the pd.set_option('display.max_colwidth', None) helped with the query but added a additional 0 and few spaces before the answer. – Amit Lohani Mar 03 '21 at 13:40