Python Forum
Unable to create csv file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to create csv file
#1
Hello

I am beginner. I am using python and tensorflow on IBM Data science experience.
I am facing a problem to create csv file (myFile.csv) in iris folder and get the error that file does not exist.

Path is correct. so Would you please guide me that why am I getting this error? so that I can solve it.

Thank you


==============
Code
==============

import os
import pandas as pd

path = "./data/samples/iris/"

filename_read = os.path.join(path,"myFile.csv")
print(filename_read)
os.path.exists("myFile.csv")
df = pd.read_csv(filename_read)
print(df)
=================
ERROR
==================
Error:
./data/samples/iris/myFile.csv --------------------------------------------------------------------------- OSError Traceback (most recent call last) <ipython-input-15-c68d1641f868> in <module>() 7 print(filename_read) 8 os.path.exists("myFile.csv") ----> 9 df = pd.read_csv(filename_read) 10 print(df) /usr/local/lib/python3.5/dist-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, skipfooter, 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, skip_footer, doublequote, delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, float_precision) 560 skip_blank_lines=skip_blank_lines) 561 --> 562 return _read(filepath_or_buffer, kwds) 563 564 parser_f.__name__ = name /usr/local/lib/python3.5/dist-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds) 313 314 # Create the parser. --> 315 parser = TextFileReader(filepath_or_buffer, **kwds) 316 317 if (nrows is not None) and (chunksize is not None): /usr/local/lib/python3.5/dist-packages/pandas/io/parsers.py in __init__(self, f, engine, **kwds) 643 self.options['has_index_names'] = kwds['has_index_names'] 644 --> 645 self._make_engine(self.engine) 646 647 def close(self): /usr/local/lib/python3.5/dist-packages/pandas/io/parsers.py in _make_engine(self, engine) 797 def _make_engine(self, engine='c'): 798 if engine == 'c': --> 799 self._engine = CParserWrapper(self.f, **self.options) 800 else: 801 if engine == 'python': /usr/local/lib/python3.5/dist-packages/pandas/io/parsers.py in __init__(self, src, **kwds) 1211 kwds['allow_leading_cols'] = self.index_col is not False 1212 -> 1213 self._reader = _parser.TextReader(src, **kwds) 1214 1215 # XXX pandas/parser.pyx in pandas.parser.TextReader.__cinit__ (pandas/parser.c:3427)() pandas/parser.pyx in pandas.parser.TextReader._setup_parser_source (pandas/parser.c:6861)() OSError: File b'./data/samples/iris/myFile.csv' does not exist
Reply


Messages In This Thread
Unable to create csv file - by Sumaira - Feb-05-2018, 09:06 AM
RE: Unable to create csv file - by buran - Feb-05-2018, 09:19 AM
RE: Unable to create csv file - by Sumaira - Feb-06-2018, 03:43 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Newbie here. Create an array from file data? Rayj00 2 1,268 Jan-13-2023, 01:35 PM
Last Post: perfringo
  Create a turtle drawing from .txt file Noob101 20 9,046 Jan-29-2021, 04:13 PM
Last Post: nilamo
  how can i create a dictionary of dictionaries from a file Astone 2 2,282 Oct-26-2020, 02:40 PM
Last Post: DeaD_EyE
  Unable to output the indices from an input file rainbow2312 1 2,989 Nov-18-2017, 05:53 PM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020