Home > other >  A novice for help! How to save the content of the for loop
A novice for help! How to save the content of the for loop

Time:09-23

The import OS
The import pdfplumber
The import re
The import pandas
The import shutil
The import pandas as pd
The import XLWT
Path="C: \ \ Users \ \ Administrator \ \ Desktop \ \ input automatically fill in the folder \ " # input path
Path2="C: \ \ Users \ \ Administrator \ \ Desktop \ \ output \ " complete order # output path
Liebiao=[]
Dirs=OS. Listdir (path)
For I in dirs:
If OS. Path. Splitext (I) [1]=="PDF" :
Liebiao. Append (I)
WJLJ=[]
X=0
For x in the range (len (liebiao)) :
A=path + liebiao [x]
WJLJ. Append (a)

For y in range (x) :
With pdfplumber. Open (WJLJ [y]) as a PDF:
For d in range (len (PDF pages)) :
Page=PDF. Pages [d]
Table=page. Extract_tables ()
For t in the table:
Df=pd DataFrame (t [1], the columns=t [0])
Df. To_excel (" C: \ \ Users \ \ Administrator \ \ Desktop \ \ reading. XLS ")



The final a set of data can only save cycle
For help
  • Related