Home > other >  Python batch processing Excel data, a great god
Python batch processing Excel data, a great god

Time:09-26



As shown in figure,
There are N pieces of different figures collected from excel table, statistical summary for each problem

Requirements:
1, when "whether there is a problem"="yes", due to the measures for each character is different, how should collect "corrective measures"
2, how to use Python batch open N excel table, and then read the form content, then summary

Much younger brother flask, GUI, crawler written, pandas and XLRD these more with less, ask the great spirit show

CodePudding user response:

Use a for loop N form open
Read the table cell, the corresponding issues in note form XLRD XLWT can only handle.xls files
Read after the cell, the corrective actions in a dictionary or array, then write a summary, of course, if the character is not much, can also be written to a string

CodePudding user response:

reference 1st floor weixin_45903952 response:
use a for loop N form open
Read the table cell, the corresponding issues in note form XLRD XLWT can only handle.xls files
Read after the cell, the corrective actions in a dictionary or array, then write a summary, of course, if the character is not much, also can write a string


Oh, suddenly had a thought, thank you, but corrective character very much

CodePudding user response:

The building Lord, you said this problem, should be better than flask, reptiles such as easier?
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Questions 1 to 9 are fixed the problem? If you are fixed more simple!
In order to facilitate future queries, it is suggested that step-by-step:
1. To establish a database table (you can copy completely EXCEL field demand, also can only design you want, of course, if to maintain data integrity, query function will be more powerful and perfect)
2. All the excel table placed in a directory, use the python traverse the all files in the directory
3. Use python loop read step 2 excel files, one file to manipulate the data written to the database table
4. Use SQL statements selected data they want (can also go to set up the view, more convenient query)

CodePudding user response:

reference paullbm reply: 3/f
the building Lord, you said this problem, should be better than flask, reptiles such as easier?
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Questions 1 to 9 are fixed the problem? If you are fixed more simple!
In order to facilitate future queries, it is suggested that step-by-step:
1. To establish a database table (you can copy completely EXCEL field demand, also can only design you want, of course, if to maintain data integrity, query function will be more powerful and perfect)
2. All the excel table placed in a directory, use the python traverse the all files in the directory
3. Use python loop read step 2 excel files, one file to manipulate the data written to the database table
4. Use SQL statements selected data they want (can also go to set up the view, more convenient query)


The problem is fixed, the equivalent of questionnaire; Database is also a method, but it seems a little complicated

CodePudding user response:

reference 4 floor yogo071328 response:
Quote: reference paullbm reply: 3/f

The building Lord, you said this problem, should be better than flask, reptiles such as easier?
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Questions 1 to 9 are fixed the problem? If you are fixed more simple!
In order to facilitate future queries, it is suggested that step-by-step:
1. To establish a database table (you can copy completely EXCEL field demand, also can only design you want, of course, if to maintain data integrity, query function will be more powerful and perfect)
2. All the excel table placed in a directory, use the python traverse the all files in the directory
3. Use python loop read step 2 excel files, one file to manipulate the data written to the database table
4. Use SQL statements selected data they want (can also go to set up the view, more convenient query)


The problem is fixed, the equivalent of questionnaire; Database is also a method, but it seems a little complicated


Database is just a way of storage, even if you don't have to database, assuming that continue to use excel, what amount of code is,
If you don't want to use the database, also don't want to use excel, that all the data in memory? If a large amount of data, more have no advantage!
In fact, the benefits of using the database is obvious, not only can let the data persistence, and have more powerful query capabilities than excel!

CodePudding user response:

reference 1st floor weixin_45903952 response:
use a for loop N form open
Read the table cell, the corresponding issues in note form XLRD XLWT can only handle.xls files
Read after the cell, the corrective actions in a dictionary or array, then write a summary, of course, if the character is not much, also can write a string


Again I ask, how to use a for loop open the excel file?

CodePudding user response:



refer to 6th floor yogo071328 response:
Quote: refer to 1st floor weixin_45903952 response:

Use a for loop N form open
Read the table cell, the corresponding issues in note form XLRD XLWT can only handle.xls files
Read after the cell, the corrective actions in a dictionary or array, then write a summary, of course, if the character is not much, also can write a string


Again I ask, how to use a for loop open the excel file?




For root, dirs, files in OS. Walk (path) :
For file in files:
If the file. The endswith (' XLS ') :

CodePudding user response:

If just for a single path
For file in OS. Walk (path) :
If the file. The endswith (' XLS ') :

CodePudding user response:

 
the import the OSPath=input (' please enter the path ')

For file in OS. Listdir (path) :
Filename=OS. Path. Join (path, file)
If OS. Path. Isfile (filename) :
If the file. The endswith (' XLS ') :
Print (file)



With this, is right

CodePudding user response:

references 9 f weixin_45903952 response:
 
the import the OSPath=input (' please enter the path ')

For file in OS. Listdir (path) :
Filename=OS. Path. Join (path, file)
If OS. Path. Isfile (filename) :
If the file. The endswith (' XLS ') :
Print (file)



Use this one instead, is to



THX, can

CodePudding user response:

references 9 f weixin_45903952 response:
 
the import the OSPath=input (' please enter the path ')

For file in OS. Listdir (path) :
Filename=OS. Path. Join (path, file)
If OS. Path. Isfile (filename) :
If the file. The endswith (' XLS ') :
Print (file)



Use this one instead, is to



 # open all excel 
For file in OS. Listdir (' excel_file) :
Filename=OS. Path. Join (' excel_file 'file)
If OS. Path. Isfile (filename) :
# open the excel file, to get the first [0] sheet name
Workbook=XLRD. Open_workbook (filename)
Sheetname=workbook. Sheet_names () [0]
Print (file, sheetname)
# for the row and column of the sheet number
Sheet=workbook. Sheet_by_index (0)
Nrow=sheet. Nrows
Print (sheet) nrows, 'line' sheet. Ncols, 'column')

# from the beginning of the line 3, read 3 columns and five columns of data
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related