Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    May 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    CSV File multiple upload - Help please! :-)

    Hello,

    I am trying to write a simple python program (in Eclipse Juno using Pydev) to load multiple .CSV files to be copied and re-outputted via CSV. (eventually the copy will be replaced with file modification then re-outputting the csv)

    So far I have got the program to upload a single CSV file and output it where the user specifies via a save dialog box (just copies the file for now).

    A dialog box pops up and asks to select files (multiple selection works) but i am not sure on how to interpret and save this multiple input of CSV files statically to an assigned location on my computer (C:/).

    Here's a simple run down of the program task:

    input CSV files -> copy -> output CSV files to static location on computer

    I will attach my code to this post,

    Any help is greatly appreciated!!

    CODE:
    ------------------------------------------------------------


    #FILE UPLOAD

    from Tkinter import Tk
    from tkFileDialog import askopenfilenames

    Tk().withdraw()
    filenames = askopenfilenames()
    print(filenames)


    #FILE COPY/MANIPULATION

    import csv
    import tkFileDialog

    ifile = open(filenames)
    reader = csv.reader(ifile)

    #SAVE AS DIALOG BOX

    ofile = tkFileDialog.asksaveasfilename()
    print filenames

    writer = csv.writer(open(ofile, 'wb'))

    for row in reader:
    writer.writerow(row)



    #STATUS DIALOG BOX

    import tkMessageBox
    tkMessageBox.showinfo(title="Conversion Successful", message="CSV File has been successfully converted")

  • #2
    New to the CF scene
    Join Date
    May 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Delete

    Mark thread for deletion


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •