skip to Main Content

I ran some commands on Jupyter Notebook and expected to get a printed output containing data in tabulated form in a .csv file, but then i get an uncompleted output
This is the result i get from the .csv file

I ran this command;

df1=pandas.read_csv("supermarkets.csv", on_bad_lines=’skip’)
df1

I expected to get a printed output in a tabulated like in the image attached……

The data get printed in well tabulated form here

Here is a link to the online version of the file

[pythonhow.com/supermarkets.csv]

3

Answers


  1. I believe there is an issue with your csv file, not the code.
    To me it looks like the data in your csv file are written in json format.
    Have you opened the supermarkets.csv file using excel? it should look like a table, not a json formatted file.

    Login or Signup to reply.
  2. did you try df1.show() to see if the csv got read in the first place?

    Login or Signup to reply.
  3. Getting good, clean quality data where the file extension correctly matches the actual content is often a challenge. Assessing the state of the input data is generally always a very important first step.
    It appears the data you are trying to get is also online here. Github will render that as a table in the browser because it has a viewer mode. To look at the ‘raw’ file content, click here. You’ll see it is nice comma-delimited file with columns separated by commas and rows each on a different line. The header with the column names is on the first line.

    Now open in a good text editor the file you have that you are working with and compare it to the content I pointed you at. That should guide you on what is the issue.
    At this point you may just wish to switch to using the version of the file that I pointed you at.

    Use the link below to obtain it as proper csv file:

    https://raw.githubusercontent.com/kenvilar/data-analysis-using-python/master/supermarkets.csv
    

    You should be able to paste that link in your browser and then right click on the page and choose ‘Save as..’ to download it to your locak machine. The obtained file should open just fine using the code you showed in the screenshot in your post here.


    Please work on writing better questions with specific titles, see here for guidance. The title at present is overly broad and is actually not accurate. This code would not work with the data you apparently have even if you were running it inside a Python code-based script. And so it is not a Jupyter notebook issue. For how to think about making it specific, a good thing to keep in mind is to write for your future self. If you continue to use notebooks you’ll have hundreds that would be considered a ‘Jupyter Notebook issue’, but what makes this issue different from those?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search