CSV input -- Formatted output

Discussion in 'Python' started by davemullen, Jan 18, 2012.

  1. davemullen

    davemullen

    Joined:
    Jan 18, 2012
    Messages:
    3
    Hi,

    I am trying to physically print letters, envelopes, labels and invoices from an ebay csv file. I can print the whole file to my screen but I can't get to the fields individually to format the printed material I listed above. I have tried using lines and csv.reader. Here are some of the fields I have to work with:
    SALES RECORD...USER ID...BUYER FULLNAME...BUYER PHONE NUMBER...BUYER EMAIL...BUYER ADDRESS 1....etc..

    I have tried many ways, sometimes I got some data to print. After I get selected fields to the screen then I want to print invoices.
    Here's the latest failure:

    import csv
    infile = csv.reader(open("fileexchange_response_123456789.csv", "rb"))
    for 'sales record', 'user id', 'buyer fullname', 'buyer phone number' in reader:
    print 'sales record', 'user id', 'buyer fullname', 'buyer phone number'
    infile.close()

    Any comment would be appreciated.
    Thanks, Dave
     
    davemullen, Jan 18, 2012
    #1
    1. Advertising

  2. davemullen

    davemullen

    Joined:
    Jan 18, 2012
    Messages:
    3
    Made some progess but I still need HELP

    I got this to dump out the header record and all the detail records nicely.
    I like the Reader because it cleans up the numeric fields.
    I still need to test a field or fields and then print fields that I select.
    What can I add to accomplish this?
    I will keep reading and testing. Thanks, Dave

    import csv
    rdr= csv.reader( open("fileexchange_response_12458229.csv", "rb" ) )
    print 'FILE BEGINS ************************************************'
    for row in rdr:
    print 'ROW BEGINS'
    # I would like to test a field or fields here
    # and print multiple fields here
    print row
    print 'ROW ENDS'
    print 'FILE ENDS ***************************************************'


    FILE BEGINS ************************************************
    ROW BEGINS
    ['Sales Record Number', 'User Id', 'Buyer Fullname', 'Buyer Phone Number', 'Buye
    r Email', 'Buyer Address 1', 'Buyer Address 2', 'Buyer City', 'Buyer State', 'Bu
    yer Zip', 'Buyer Country', 'Order ID', 'Item ID', 'Transaction ID', 'Item Title'
    , 'Quantity', 'Sale Price', 'Shipping And Handling', 'Sales Tax', 'Insurance', '
    Total Price', 'Payment Method', 'PayPal Transaction ID', 'Sale Date', 'Checkout
    Date', 'Paid on Date', 'Shipped on Date', 'Shipping Service', 'Feedback Left', '
    Feedback Received', 'Notes to Yourself', 'Custom Label', 'Listed On', 'Sold On',
    'Variation Details']
    ROW ENDS
    ROW BEGINS
    real data records not shown
     
    davemullen, Jan 18, 2012
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    3
    Views:
    455
    Eric Reitmaier
    Oct 19, 2004
  2. Ram Laxman
    Replies:
    22
    Views:
    938
    Programmer Dude
    Feb 11, 2004
  3. Ram Laxman

    How to Parse a CSV formatted text file

    Ram Laxman, Feb 7, 2004, in forum: C Programming
    Replies:
    22
    Views:
    1,145
    Programmer Dude
    Feb 11, 2004
  4. dkk

    formatted input/output question

    dkk, Apr 10, 2006, in forum: C Programming
    Replies:
    2
    Views:
    335
    Herbert Rosenau
    Apr 12, 2006
  5. redcic
    Replies:
    6
    Views:
    354
    Dave Borne
    May 2, 2007
Loading...

Share This Page