#๐Ÿ”’ help needed with this statement i need output given automatically from a csv file

31 messages ยท Page 1 of 1 (latest)

rose pulsarBOT
#

@dapper ridge

Python help channel opened

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.

exotic crystal
#

Do you have an example CSV file?

#

What code do you have so far?

dapper ridge
#

i just need a code working to work out the busiest traffic hours

#

@exotic crystal

wheat thicket
dapper ridge
#

im not sure how u work it out

nimble adder
#

!doc csv

rose pulsarBOT
#
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.

dapper ridge
exotic crystal
dapper ridge
exotic crystal
#

Both

dapper ridge
#

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

exotic crystal
dapper ridge
#

import csv

dapper ridge
exotic crystal
#

!code

rose pulsarBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

exotic crystal
dapper ridge
#

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

dapper ridge
#

the numbers mean the columns in the csv files

exotic crystal
#

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

rose pulsarBOT
#
Python help channel closed

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