#๐ help needed with this statement i need output given automatically from a csv file
31 messages ยท Page 1 of 1 (latest)
@dapper ridge
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
what do you have tried and where is the problem with your code?
im not sure how u work it out
First thing is to load the CSV file. See the CSV module docs: https://docs.python.org/3/library/csv.html#module-csv
!doc csv
Source code: Lib/csv.py
The so-called CSV (Comma Separated Values) format is the most common import and export format for spreadsheets and databases. CSV format was used for many years prior to attempts to describe the format in a standardized way in RFC 4180. The lack of a well-defined standard means that subtle differences often exist in the data produced and consumed by different applications. These differences can make it annoying to process CSV files from multiple sources. Still, while the delimiters and quoting characters vary, the overall format is similar enough that it is possible to write a single module which can efficiently manipulate such data, hiding the details of reading and writing the data from the programmer.
ive done this i just a command to print it
Ok paste that code here
which
Both
if row[0] == "Hanley Highway/Westway":
hour = row[1].split(':')[0] # Adjust index if needed
traffic_count = int(row[2]) # Convert traffic count to integer if in row[2]
if hour in hour_counts:
hour_counts[hour] += traffic_count
else:
hour_counts[hour] = traffic_count
busiest_hour = max(hour_counts, key=hour_counts.get)
max_traffic = hour_counts[busiest_hour]
print(f"The busiest hour for Hanley Highway/Westway is {busiest_hour}:00 with {max_traffic} vehicles.")
like this is code but not working
Please remember to use code blocks and always paste the whole file, including imports
import csv
this the code i need fixing
!code
What's the code doing? I can't diagnose it from "not working" you need to elaborate on the difference between what it does and what it should do
basically from the csv file i need an output of what the time of the busiest traffic hour on Hanley Highway/Westway the python file should automatically identify what the number is
i have written this code for it, it doesnt wokr
the numbers mean the columns in the csv files
You need to describe the way that it doesn't work
From what you sent me, If I tried to run it, it would have a SyntaxError
You need to send me the code, as if you thought I was going to run it
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.
๐ help needed with this statement i need output given automatically from a csv file