Python Forum
hi guys, i'm back to learning python !
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
hi guys, i'm back to learning python !
#5
There is some low level stuff you can let csv module to handle. For example, if there is a file with one row: "AAPL", 113.02 then we can leave handling of "" and conversion to csv module:

import csv


with open('aapl.csv', 'r') as f:
    reader = csv.reader(f, quoting=csv.QUOTE_NONNUMERIC)
    print(*reader)

# -> ['AAPL', 113.02]


with open('aapl.csv', 'r') as f:
    data = [item for row in f for item in row.strip().split(', ')]
    print(data)

# -> ['"AAPL"', '113.02']
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.
Reply


Messages In This Thread
RE: hi guys, i'm back to learning python ! - by perfringo - Oct-05-2020, 08:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  front-end js and back-end python 3lnyn0 0 1,029 Jun-03-2022, 08:51 PM
Last Post: 3lnyn0
  guys please help me , pycharm is not able to identify my xlsx file CrazyGreenYT7 1 2,050 Jun-13-2021, 02:22 PM
Last Post: Larz60+
  Virtual Assistant code is looping back in python ShishirModi 1 2,590 Oct-13-2020, 08:04 AM
Last Post: Nickd12
  Hi Guys, please help me to write SAS macro parameter equivalent code in Python Manohar9589 2 2,656 Jun-14-2020, 05:07 PM
Last Post: Larz60+
  Could you guys help with this bug. I would post on StackOverflow but I got tempbanned ryder5227 2 2,451 Sep-26-2019, 08:01 PM
Last Post: metulburr
  Help Please guys AbuSiraj 2 2,741 Feb-14-2019, 09:29 AM
Last Post: AbuSiraj
  Hey guys, help a newbie out with a list problem. sdezigner 2 2,721 Feb-15-2018, 06:06 PM
Last Post: sdezigner
  Hello,Guys!,I met a very strange bug homepoeple 4 3,380 Jan-26-2018, 12:16 PM
Last Post: homepoeple
  Hey guys can you please help me with some basic coding Stabu 9 6,405 Jul-16-2017, 10:11 AM
Last Post: MyImpsNamesAre

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020