Skip to content

HevaWu/CSVReader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSVReader

This is a simple code for transferring Excel file to CSV file. Then read the data in it.

Basic Structure:

  • Error.py:
    • Error: An exception for error in it
  • CSVReader.py:
    • CSVFileName: An Enum object, which list all of the sheet name, you could directly read each csv by its name
    • CSVColumnName: An Enum object, which list all of the column you might needed
    • CSVReader:
      • init method need to pass filename, which is the .CSV file
      • Use getColumn(columnName) function to get all of the data in this column, (NOTE: this function also formatting the data in it, all of the duplicate & empty elements will be removed)
      • Use getDataSource() function to get all of the data in this file
  • generateCSV.py
    • Directly call Autogenerator('TextExcel.xlsx')(Your file name) is okay

How to run it:

After installing python, directly run python3 generateCSV.py (My environment is Python3.6) would be okay.

Here is the snapshot of my TextExcel.xlsx Excel: Screen Shot 2019-07-04 at 18 57 53 Screen Shot 2019-07-04 at 18 57 44

Here is the output:

HealthyFood
Weather
HealtyFood Sheet: 
[{'Name': 'Orange', 'Types': 'Citrus', 'Category': 'Fruit'}, {'Name': 'Grapefruit', 'Types': 'Citrus', 'Category': 'Fruit'}, {'Name': 'Mandarins', 'Types': 'Citrus', 'Category': 'Fruit'}, {'Name': 'Nectarines', 'Types': 'Stone Fruit', 'Category': 'Fruit'}, {'Name': 'Apricots', 'Types': 'Stone Fruit', 'Category': 'Fruit'}, {'Name': 'Peaches', 'Types': 'Stone Fruit', 'Category': 'Fruit'}, {'Name': 'Bananas', 'Types': 'Tropical and exotic', 'Category': 'Fruit'}, {'Name': 'Mangoes', 'Types': 'Tropical and exotic', 'Category': 'Fruit'}, {'Name': 'Watermelons', 'Types': 'Melons', 'Category': 'Fruit'}, {'Name': 'Lettuce', 'Types': 'Leafy Green', 'Category': 'Vegetables'}, {'Name': 'Cabbage', 'Types': 'Cruciferous', 'Category': 'Vegetables'}, {'Name': 'Spinach', 'Types': 'Leafy Green', 'Category': 'Vegetables'}, {'Name': 'Pumpkin', 'Types': 'Marrow', 'Category': 'Vegetables'}, {'Name': 'Cucumber', 'Types': 'Marrow', 'Category': 'Vegetables'}, {'Name': 'Potato', 'Types': 'Root', 'Category': 'Vegetables'}, {'Name': 'Sweet Potato', 'Types': 'Root', 'Category': 'Vegetables'}, {'Name': 'Onion', 'Types': 'Allium', 'Category': 'Vegetables'}]
[{'Name': 'Orange', 'Types': 'Citrus', 'Category': 'Fruit'}, {'Name': 'Grapefruit', 'Types': 'Citrus', 'Category': 'Fruit'}, {'Name': 'Mandarins', 'Types': 'Citrus', 'Category': 'Fruit'}, {'Name': 'Nectarines', 'Types': 'Stone Fruit', 'Category': 'Fruit'}, {'Name': 'Apricots', 'Types': 'Stone Fruit', 'Category': 'Fruit'}, {'Name': 'Peaches', 'Types': 'Stone Fruit', 'Category': 'Fruit'}, {'Name': 'Bananas', 'Types': 'Tropical and exotic', 'Category': 'Fruit'}, {'Name': 'Mangoes', 'Types': 'Tropical and exotic', 'Category': 'Fruit'}, {'Name': 'Watermelons', 'Types': 'Melons', 'Category': 'Fruit'}, {'Name': 'Lettuce', 'Types': 'Leafy Green', 'Category': 'Vegetables'}, {'Name': 'Cabbage', 'Types': 'Cruciferous', 'Category': 'Vegetables'}, {'Name': 'Spinach', 'Types': 'Leafy Green', 'Category': 'Vegetables'}, {'Name': 'Pumpkin', 'Types': 'Marrow', 'Category': 'Vegetables'}, {'Name': 'Cucumber', 'Types': 'Marrow', 'Category': 'Vegetables'}, {'Name': 'Potato', 'Types': 'Root', 'Category': 'Vegetables'}, {'Name': 'Sweet Potato', 'Types': 'Root', 'Category': 'Vegetables'}, {'Name': 'Onion', 'Types': 'Allium', 'Category': 'Vegetables'}]
Weather Sheet: 
[{'Location': 'Chicago', 'Weather Forecasts': 'Cloudy'}, {'Location': 'London', 'Weather Forecasts': 'Sunny'}, {'Location': 'Tbilisi', 'Weather Forecasts': 'Sunny'}, {'Location': 'Dakar', 'Weather Forecasts': 'Cloudy'}, {'Location': 'San Jose', 'Weather Forecasts': 'Rainy'}]
[{'Location': 'Chicago', 'Weather Forecasts': 'Cloudy'}, {'Location': 'London', 'Weather Forecasts': 'Sunny'}, {'Location': 'Tbilisi', 'Weather Forecasts': 'Sunny'}, {'Location': 'Dakar', 'Weather Forecasts': 'Cloudy'}, {'Location': 'San Jose', 'Weather Forecasts': 'Rainy'}]

About

Transfer excel data to csv format. Then parsing it to get each columns data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages