Overwriting Csv Database

Discussion in 'Databases' started by sstoney200, Jan 25, 2013.

  1. #1
    Hi guys, I wanna pick some brains if possible? ;)

    I'm going to email a campaign using mailchimp contacts retrieved from a CSV file.

    The Mailchimp campaign is intended to verify the customer details within the CSV Database.

    Here follows the tricky part:

    The fields displayed in the email will be such like name, email, telephone number, and if the contact details are ok, it will require no further actions from the user.

    However, if the details are not correct, I want to forward the user from the email to a landing page on our site. The site will populate the exact same fields (retrieving from the email fields) and allow the user to overwrite their incorrect details, before saving to/overwriting the original CSV database.

    I wonder if any whizzes on here can tell me how difficult a task that is?

    Thanks in advance!
    Jamie
     
    sstoney200, Jan 25, 2013 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    You can't edit a text file (which is what a csv file is) in place. You have to read the entire file, change the data in the row that has to be changed, then write out the entire file. How difficult? Trivial if you know how to read and write files (and develop web pages), impossible if you don't.
     
    Rukbat, Jan 25, 2013 IP
  3. sstoney200

    sstoney200 Greenhorn

    Messages:
    73
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    Hi Rukbat,

    I have a fair amount of exp. deveoping web pages using (for instance) MYSQL and the like. But not overwriting CSV files. So any help/pointing in the right direction would be much appreciated! ;)
     
    sstoney200, Jan 28, 2013 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    Just as I said - read the entire file - into an array of lines or a single string, your choice. Make whatever changes you want. Open the file for write (deleting everything in it) and write the text out to the file.
     
    Rukbat, Jan 28, 2013 IP