The file I had created myself but I have realized that the problem was with the path to the file. Django request.POST['file'] uses an "InMemoryUploadedFile" to handle file upload. And I could not explicitly reference the path of the file from the fileupload input, and parse directly into "pandas.read_csv" function. But, I have managed to manipulate the "csv.read" to work in my favor now. Thank you for the suggestions though. Very much appreciated.
On Tue, May 26, 2020 at 2:38 PM Jason Turner <[email protected]> wrote: > Is the csv something you created? Or was it given to you? > > I use pandas extensively & the times I've received that error, the issue > has been with the file itself. > > Ard there blank line(s) at the top of the file? > > On Tue, May 26, 2020, 4:11 AM jakote lejaha <[email protected]> > wrote: > >> The same very same file works fine for the python "csv.reader" function >> with the other parameter as (delimiter=",") other than the file itself. >> I recently added names attribute as a parameter to the "pandas.read_csv" >> function, but I can still not get my table as expected. Instead, I >> get an empty df. Example below: >> >> Empty DataFrame >> Columns: [name, date_time, image, place] >> Index: [] >> >> On Tuesday, May 26, 2020 at 2:23:58 AM UTC+2, J.T. wrote: >>> >>> Are you sure the file is coma delimited? This error is usually because >>> the file is not coma separated. >>> >>> On Mon, May 25, 2020, 5:04 PM jakote lejaha <[email protected]> wrote: >>> >>>> Ideally I would have wanted to use the "csv.reader" function, but in >>>> this case it becomes complicated as I would like to load the cvs file to my >>>> web template before I decide if I want to save it to the database or not. >>>> So I opt for reading the file using pandas as it's easy to display the >>>> records to the HTML tags. But however, I keep getting the error below. >>>> >>>> >>>> File "pandas\_libs\parsers.pyx", line 532, in >>>> pandas._libs.parsers.TextReader.__cinit__ >>>> <source code not available> >>>> >>>> Exception Type: EmptyDataError at /upload_reading >>>> Exception Value: No columns to parse from file >>>> >>>> >>>> >>>> How do I fix this? >>>> >>>> >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Django users" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/django-users/72b3aabd-3930-43ab-821f-e43bc23568e4%40googlegroups.com >>>> <https://groups.google.com/d/msgid/django-users/72b3aabd-3930-43ab-821f-e43bc23568e4%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/4e0a6361-f3f2-4005-ac2a-627f1b5076dc%40googlegroups.com >> <https://groups.google.com/d/msgid/django-users/4e0a6361-f3f2-4005-ac2a-627f1b5076dc%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CADoyC177kKB4Af9SZPB4PNta2QvpzmC%2B-Y8d-vmPRDgHroBB0g%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CADoyC177kKB4Af9SZPB4PNta2QvpzmC%2B-Y8d-vmPRDgHroBB0g%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACjM_Be%3D1es7rZXyOZJLPHuOx6GCAa3U_EZCzLP4f78RcH1Z%3Dg%40mail.gmail.com.

