This Python script processes and combines population and energy price data into a unified file named valinfo.csv. The population data in the resulting output file will pertain to MODEL IIASA-WiC POP and SCENARIO SSP3 v9 130115.
The program consists of two scripts:
data-fusion.py- This main script processes population and energy price data, merges them, & saves the combined data to a CSV file.compare-files.py- This script compares the generated CSV file with an original CSV file to ensure the data is consistent.
Data files (located in data directory):
IEA_Price_FIN_Clean_gr014_GLOBAL.dta(input file: this is a STATA dataset)population.csv(input file)valinfo_orig.csv(this is the original valinfo file to be used for comparasion with the generated output)
- Python 3.x
- pandas
- numpy
- warnings
- os
-
Clone the repository:
git clone https://github.com/babak2/DataFusion.git cd DataFusion -
Install the required Python packages:
pip install pandas numpy
-
Description:
- The
data-fusion.pyscript loads population data and energy price data, processes and merges them, & saves the result to a CSV file in the output directory.
- The
-
Running the Script:
If Python 3 is the only Python version installed on your machine, you can use the python command. For example:
python data-fusion.py
If both Python 2 and 3 are both installed, it's important to specify Python 3 using the python3 command. For example:
python3 data-fusion.py
- Output:
- The combined data is saved as
valinfo.csvin theoutputdirectory.
- The combined data is saved as
-
Description:
- The
compare-files.pyscript compares the generated CSV file (output/valinfo.csv) with the original CSV file (data/valinfo_orig.csv) to ensure they contain the same data.
- The
-
Running the Script:
python3 compare-files.py -
Output:
- The script prints (to the terminal) whether the files contain the same data or not. If there are differences, it prints the differences between the files.
Babak Mahdavi Aresetani