Calling 3-column CSV file in Python

Asked

Viewed 46 times

0

I’m trying to call the file temperature.csv in Python but shows with errors, IE, I wanted to appear the three columns.

The code I made was this::

import pandas as pd 
dataset= pd.read_csv("c:\\Users\\smnm2\\Documents\\temperature.csv", encoding="ISO-8859-1", header=None)
print(dataset)

The result was:

runfile('C:/Users/smnm2/chamada.py', wdir='C:/Users/smnm2')
                                                     0
0                                Timestamp;Temperature
1    Tue Apr 23 2019 11:49:21 GMT+0100 (GMT+01:00);...
2    Tue Apr 23 2019 11:50:15 GMT+0100 (GMT+01:00);...
3    Tue Apr 23 2019 11:50:15 GMT+0100 (GMT+01:00);...
4    Tue Apr 23 2019 11:50:55 GMT+0100 (GMT+01:00);...
5    Tue Apr 23 2019 11:51:45 GMT+0100 (GMT+01:00);...
6    Tue Apr 23 2019 11:52:35 GMT+0100 (GMT+01:00);...
7    Tue Apr 23 2019 11:53:05 GMT+0100 (GMT+01:00);...
8    Tue Apr 23 2019 11:53:45 GMT+0100 (GMT+01:00);...
9    Tue Apr 23 2019 11:55:01 GMT+0100 (GMT+01:00);...
10   Tue Apr 23 2019 11:55:01 GMT+0100 (GMT+01:00);...
11   Tue Apr 23 2019 11:55:32 GMT+0100 (GMT+01:00);...
12   Tue Apr 23 2019 11:56:32 GMT+0100 (GMT+01:00);...
13   Tue Apr 23 2019 11:56:32 GMT+0100 (GMT+01:00);...
14   Tue Apr 23 2019 11:57:17 GMT+0100 (GMT+01:00);...
15   Tue Apr 23 2019 11:57:59 GMT+0100 (GMT+01:00);...
16   Tue Apr 23 2019 11:59:09 GMT+0100 (GMT+01:00);...
17   Tue Apr 23 2019 11:59:19 GMT+0100 (GMT+01:00);...
18   Tue Apr 23 2019 11:59:59 GMT+0100 (GMT+01:00);...
19   Tue Apr 23 2019 12:00:39 GMT+0100 (GMT+01:00);...
20   Tue Apr 23 2019 12:00:59 GMT+0100 (GMT+01:00);...
21   Tue Apr 23 2019 12:01:29 GMT+0100 (GMT+01:00);...
22   Tue Apr 23 2019 12:01:39 GMT+0100 (GMT+01:00);...
23   Tue Apr 23 2019 12:02:26 GMT+0100 (GMT+01:00);...
24   Tue Apr 23 2019 12:02:46 GMT+0100 (GMT+01:00);...
25   Tue Apr 23 2019 12:02:56 GMT+0100 (GMT+01:00);...
26   Tue Apr 23 2019 12:08:01 GMT+0100 (GMT+01:00);...
27   Tue Apr 23 2019 12:10:23 GMT+0100 (GMT+01:00);...
28   Tue Apr 23 2019 12:11:46 GMT+0100 (GMT+01:00);...
29   Tue Apr 23 2019 12:14:16 GMT+0100 (GMT+01:00);...
..                                                 ...
578  Wed Apr 24 2019 17:49:02 GMT+0100 (GMT+01:00);...
579  Wed Apr 24 2019 17:51:40 GMT+0100 (GMT+01:00);...
580  Wed Apr 24 2019 17:51:40 GMT+0100 (GMT+01:00);...
581  Wed Apr 24 2019 17:53:10 GMT+0100 (GMT+01:00);...
582  Wed Apr 24 2019 17:55:47 GMT+0100 (GMT+01:00);...
583  Wed Apr 24 2019 17:55:47 GMT+0100 (GMT+01:00);...
584  Wed Apr 24 2019 17:56:17 GMT+0100 (GMT+01:00);...
585  Wed Apr 24 2019 17:59:17 GMT+0100 (GMT+01:00);...
586  Wed Apr 24 2019 17:59:17 GMT+0100 (GMT+01:00);...
587  Wed Apr 24 2019 18:02:17 GMT+0100 (GMT+01:00);...
588  Wed Apr 24 2019 18:03:57 GMT+0100 (GMT+01:00);...
589  Wed Apr 24 2019 18:03:57 GMT+0100 (GMT+01:00);...
590  Wed Apr 24 2019 18:05:12 GMT+0100 (GMT+01:00);...
591  Wed Apr 24 2019 18:05:27 GMT+0100 (GMT+01:00);...
592  Wed Apr 24 2019 18:08:12 GMT+0100 (GMT+01:00);...
593  Wed Apr 24 2019 18:08:27 GMT+0100 (GMT+01:00);...
594  Wed Apr 24 2019 18:11:12 GMT+0100 (GMT+01:00);...
595  Wed Apr 24 2019 18:14:12 GMT+0100 (GMT+01:00);...
596  Fri Apr 26 2019 09:13:31 GMT+0100 (GMT+01:00);...
597  Fri Apr 26 2019 09:14:31 GMT+0100 (GMT+01:00);...
598  Fri Apr 26 2019 09:17:31 GMT+0100 (GMT+01:00);...
599  Fri Apr 26 2019 09:23:31 GMT+0100 (GMT+01:00);...
600  Fri Apr 26 2019 09:26:31 GMT+0100 (GMT+01:00);...
601  Fri Apr 26 2019 09:29:31 GMT+0100 (GMT+01:00);...
602  Fri Apr 26 2019 09:32:31 GMT+0100 (GMT+01:00);...
603  Fri Apr 26 2019 09:35:31 GMT+0100 (GMT+01:00);...
604  Fri Apr 26 2019 09:41:31 GMT+0100 (GMT+01:00);...
605  Fri Apr 26 2019 09:44:31 GMT+0100 (GMT+01:00);...
606  Fri Apr 26 2019 09:50:32 GMT+0100 (GMT+01:00);...
607  Fri Apr 26 2019 09:56:32 GMT+0100 (GMT+01:00);...

[608 rows x 1 columns]

The value of the column Temperature does not appear, I wanted to appear the three separate columns correctly. Where I am missing?

2 answers

2


If you set a separator, sure. Do it like this:

df = pd.read_csv('file.csv', sep=';', encoding="ISO-8859-1", header=None)

Since apparently the columns are separated by ';'

  • 1

    Thanks, it worked out!!!

0

Try what the above colleague said, but try to look at the structure of your file before, it really seems to be the ';' tab. Particularly I prefer to adjust the csv before, placing the separator as ',' and correctly adjusting the columns.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.