skip to Main Content

enter image description here
I am getting this result in vs code but it is working in Pycharm and I have used the complete path of the file in both softwares…
what should i do?
is there some setting which i have to do? Also when using just the file name instead of the complete path, both pycharm and vs code are showing the file doesn’t exist..

3

Answers


  1. use the below code

    work = open(r'/Users/Documents/Python_Programs/files/china.csv','r')
    working = work.read()
    work.close()
    
    print(working)
    

    The variable work return the file object (we are using open() function).
    The variable working return the file content (we are using read() function)

    Login or Signup to reply.
  2. print(working) rather than print(work)

    Or (better):

    with open(r"C:Usersuservs.csv", "r") as data:
        print(data.read())
    
    Login or Signup to reply.
  3. You can install pandas package by command pip install pandas to read csv file. Using the following codes:

    import pandas as pd
    # reading csv file
    df = pd.read_csv(r"C:Usersuservs.csv")
    print(df.head())
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search