Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 question by a beginner
#11
Example.
import csv

with open('csv_data.csv') as csvfile:
    reader = csv.reader(csvfile, delimiter=';')
    for row in reader:
        print(','.join(row))
Output:
name, age, number Salah, 22, 1, 26/01, ali, 23, 2, 26/01, Ranard, 30, 3, 26/01
For Pandas look at this post.
Quote
#12
(Jan-27-2019, 06:58 PM)salahoum Wrote: I explained my problem but the idea did not arrive
I simply re-explain
the videos in YouTube they read the data from the csv file like:

name, age, number, and the date; Salah; 22; 1; 26/01; ali; 23; 2; 26/01; Ranard; 30; 3; 26/01

I need to display it as:

name number date
salah 22 1 1/26
ali 23 2 26/01
ranard 30 3 26/01

There are three column headers (name, number, date) but four data columns separated by tab. Is it typo? What does mean 'display'? Is there one long row or data is on separate rows?

Based on limited knowledge a would propose something along those lines:

>>> s = ['name; age; number; date',
...      'Salah; 22; 1; 26/01',
...      'ali; 23; 2; 26/01',
...      'Ranard; 30; 3; 26/01']
>>> for row in s:
...     print(*row.split(';'))
name  age  number  date
Salah  22  1  26/01
ali  23  2  26/01
Ranard  30  3  26/01
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Super easy beginner question AkulaLA 3 107 Nov-07-2019, 03:42 AM
Last Post: Larz60+
  Basic Beginner question NHeav 4 209 Sep-13-2019, 11:43 AM
Last Post: NHeav
  Beginner Question - Esaping the Escape Character correctly? Bramen 4 310 Aug-27-2019, 02:38 PM
Last Post: Bramen
  beginner question Naito 2 388 Jan-15-2019, 07:59 AM
Last Post: Naito
  "if" beginner question Naito 13 1,197 Jan-13-2019, 02:15 PM
Last Post: perfringo
  Absolute Beginner Python Question matchamochi7 5 802 Nov-02-2018, 12:09 PM
Last Post: wookie
  Beginner Loop question BigDisAok 5 879 Jul-24-2018, 02:04 PM
Last Post: BigDisAok
  Beginner question: help ensuring input is a number ycrad 2 953 Dec-23-2017, 10:49 PM
Last Post: snippsat
  Beginner question HimynameisBen 4 1,193 Nov-03-2017, 07:58 PM
Last Post: nilamo
  Total beginner question AngelForge 8 2,331 Apr-08-2017, 07:19 AM
Last Post: Low_Ki_

Forum Jump:


Users browsing this thread: 1 Guest(s)