Home > Net >  Read the contents of text file into a pandas dataframe from a zip folder
Read the contents of text file into a pandas dataframe from a zip folder

Time:11-21

I have a zip file and inside the zip file, I have a series of folders that in turn contains text files. Like below.


  zip1 
     - folder 1
       - folder x
         - file1.txt
         - file2.txt
       - folder y
         - file3.txt
         - file4.txt
       - folder z
         - file6.txt
         - file7.txt
     - folder 2
       - folder m
         - file9.txt
         - file10.txt
       - folder n
         - file11.txt
         - file12.txt

I tried to extract the contents of the text file using pandas, based on the enter image description here

If needed, you can use pandas.DataFrame.to_csv to save the amount of data you need as a csv.

  • Related