p2
This commit is contained in:
2
WS24_25/PyCharm/pythonProject/.idea/misc.xml
generated
2
WS24_25/PyCharm/pythonProject/.idea/misc.xml
generated
@@ -3,5 +3,5 @@
|
|||||||
<component name="Black">
|
<component name="Black">
|
||||||
<option name="sdkName" value="Python 3.12 (pythonProject)" />
|
<option name="sdkName" value="Python 3.12 (pythonProject)" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (pythonProject)" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (pythonProject)" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Python 3.11 (pythonProject)" jdkType="Python SDK" />
|
<orderEntry type="jdk" jdkName="Python 3.8 (pythonProject)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
2931
WS24_25/PyCharm/pythonProject/P2/AmesHousing.csv
Normal file
2931
WS24_25/PyCharm/pythonProject/P2/AmesHousing.csv
Normal file
File diff suppressed because it is too large
Load Diff
55672
WS24_25/PyCharm/pythonProject/P2/AmesHousing.json
Normal file
55672
WS24_25/PyCharm/pythonProject/P2/AmesHousing.json
Normal file
File diff suppressed because it is too large
Load Diff
29
WS24_25/PyCharm/pythonProject/P2/cvsToJson.py
Normal file
29
WS24_25/PyCharm/pythonProject/P2/cvsToJson.py
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
def csv_to_json(input_file: str, output_file: str):
|
||||||
|
data = []
|
||||||
|
|
||||||
|
# Step 1: Read the CSV file manually
|
||||||
|
with open(input_file, 'r') as file:
|
||||||
|
lines = file.readlines()
|
||||||
|
|
||||||
|
# Step 2: Parse the first line to get the headers
|
||||||
|
headers = lines[0].strip().split(';')
|
||||||
|
|
||||||
|
# Step 3: Parse the subsequent lines to get the data
|
||||||
|
for line in lines[1:]:
|
||||||
|
values = line.strip().split(';')
|
||||||
|
# Create a dictionary for each row
|
||||||
|
row_dict = {headers[i]: values[i] for i in range(len(headers))}
|
||||||
|
data.append(row_dict)
|
||||||
|
|
||||||
|
# Step 4: Save the data to a JSON file
|
||||||
|
with open(output_file, 'w') as json_file:
|
||||||
|
json.dump(data, json_file, indent=4)
|
||||||
|
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
input_csv_file = 'AmesHousing.csv'
|
||||||
|
output_json_file = 'AmesHousing.json'
|
||||||
|
csv_to_json(input_csv_file, output_json_file)
|
||||||
19
WS24_25/PyCharm/pythonProject/P2/summary.py
Normal file
19
WS24_25/PyCharm/pythonProject/P2/summary.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
|
||||||
|
def summarize_csv(file_path: str):
|
||||||
|
# Step 1: Load the CSV file using pandas
|
||||||
|
df = pd.read_csv(file_path, delimiter=';')
|
||||||
|
|
||||||
|
# Step 2: Print general information about the data
|
||||||
|
print("Data Info:")
|
||||||
|
print(df.info())
|
||||||
|
|
||||||
|
# Step 3: Print statistical summary of the numerical columns
|
||||||
|
print("\nStatistical Summary:")
|
||||||
|
print(df.describe())
|
||||||
|
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
input_csv_file = 'AmesHousing.csv'
|
||||||
|
summarize_csv(input_csv_file)
|
||||||
Reference in New Issue
Block a user