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

Life of Brian: Conjugate the verb, "to go" !
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Help for beginner :) Ondra 1 237 Feb-14-2019, 02:31 PM
Last Post: buran
  beginner question Naito 2 297 Jan-15-2019, 07:59 AM
Last Post: Naito
  "if" beginner question Naito 13 911 Jan-13-2019, 02:15 PM
Last Post: perfringo
  Absolute Beginner Python Question matchamochi7 5 606 Nov-02-2018, 12:09 PM
Last Post: wookie
  Very beginner but please help! thurpe 2 492 Jul-31-2018, 04:04 PM
Last Post: thurpe
  Beginner Loop question BigDisAok 5 750 Jul-24-2018, 02:04 PM
Last Post: BigDisAok
  beginner Kyrophis 1 555 Jun-26-2018, 05:25 PM
Last Post: Larz60+
  Very beginner needs help bostltch 3 849 Feb-04-2018, 12:17 AM
Last Post: Larz60+
  Beginner question: help ensuring input is a number ycrad 2 826 Dec-23-2017, 10:49 PM
Last Post: snippsat
  Beginner question HimynameisBen 4 1,079 Nov-03-2017, 07:58 PM
Last Post: nilamo

Forum Jump:


Users browsing this thread: 1 Guest(s)