Demo project for parsing Excel files to CSV using pandas. The commands in this README are for Windows.
- Install Visual Studio Code (or other IDE)
- Install Python
- Use pip to install virtualenv
pip install virtualenv
- Clone the repository
- Go to https://github.com/jobdenotter/parse_excel, click on the green button 'Code' and copy the address for HTTPS.
- Open a command line and navigate to the folder where you want to store the repository.
- type
git clone [copied address]
(which should result ingit clone https://github.com/jobdenotter/parse_excel.git
).
- Navigate to the repository
- Execute the command
virtualenv venv
(venv is a common name for a virtual environment) - Execute the command
source venv/Scripts/activate
to activate your virtual environment (you can deactivate it by simply using the commanddeactivate
). - When activated, you can install all the requirements by executing the command
pip install -r requirements.txt
. This will read all the required packages from the file requirements.txt and install them in the virualenv (make sure it is activated).
You can run any Python file from the command line using py [filename]
. E.g. py main.py
.
When you execute the program, it will print the dataframe
column 1 | column 2 | |
---|---|---|
0 | a | d |
1 | b | e |
2 | c | f |
Your challenge is to use pandas to_csv and pandas rename to generate a CVS file example.csv
which looks like:
Instrument | Price |
---|---|
TSLA | 1 |
AAPL | 2 |
MSFT | 3 |
I.E.
Instrument,Price
TSLA,1
AAPL,2
MSFT,3
- Try splitting the task into different steps.
- You can access and modify elements of the pandas dataframe using
df[<column name>][<row index>]
. - Read the documentation of pandas to_csv and pandas rename.