Data Analysis with Python syntax error while reading csv in replit

import pandas as pd
df = pd.read_csv("adult.data.csv" )
print(df.head())

when running in replit console or somwhere else everything works fine, but when runnig a .py file with this code in replit it gives error:
File “adult.data.csv”, line 2
39,State-gov,77516,Bachelors,13,Never-married,Adm-clerical,Not-in-family,White,Male,2174,0,40,United-States,<=50K
^
SyntaxError: invalid syntax

Please help

try that way without the print
image
and without any spaces inside the ( )

still the same error

You will probably need to post a link to your repl for debugging. I don’t think there is enough information here to solve the problem.

sure, here it is: https://replit.com/@aksmolop/boilerplate-demographic-data-analyzer#demographic_data_analyzer.py

Looks like you have a bad repl for whatever reason. I cloned the boilerplate and could read the data CSV without problem. Just clone the repl boilerplate again and copy/paste whatever analysis code you may have had and try again.

cloning repl again helped, thank you very much for your help!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.