# Setting the current working directory%config IP...

Discussion in 'General Discussions' started by _27317, Jul 8, 2018.

  1. _27317

    _27317 Member
    Alumni

    Joined:
    Mar 27, 2018
    Messages:
    4
    Likes Received:
    0
    # Setting the current working directory
    %config IPCompleter.greedy = True
    import os
    print(os.getcwd())
    os.chdir("C:\\Users\\jamu\\.anaconda\\MyLab")
    print("Test 1")
    print(os.getcwd())

    # importing the dataset
    mydata = pd.read_csv("Data.csv")


    Below is the error

    ParserError Traceback (most recent call last)
    <ipython-input-39-ce383693554c> in <module>()
    1 # importing the dataset
    ----> 2 mydata = pd.read_csv("Data.csv")
    3 #mydata = pd.read_csv(open("/Users/jamu/.anaconda/MyLab/Data.csv",'r'), header=None,encoding='utf-8', engine='c')
    4 #pd.read_csv(open('./myfile.txt','r'), header=None,encoding='utf-8', engine='c')

    ~\Anaconda3\lib\site-packages\pandas\io\parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, doublequote, delim_whitespace, low_memory, memory_map, float_precision)
     
    #1
  2. Vikas Kumar_18

    Vikas Kumar_18 Active Member
    Simplilearn Support Alumni

    Joined:
    Dec 17, 2018
    Messages:
    25
    Likes Received:
    0
    Hi Learner,

    Just change this excerpt code mentioned below and let me know does it work fine?
    You have to add "encoding='utf-8" while loading the file.

    # importing the dataset:
    mydata = pd.read_csv("Data.csv",encoding='utf-8')


    Regards,
    VIKAS KUMAR
    Lead-Global Teaching Assistant

    Simplilearn
    1 million+happy learners
    Facebook | Linkedin | Twitter | YouTube
    Digital economy training
     
    #2

Share This Page