Skip to content

Importing Users - Update fields option

vsmvsm
edited June 2013 in Suggestions

Hi Ben,

I see that when one re-imports users, their information (Name) remains unchanged and we have to do this manually for each subscriber.
I suggest that a "Update fields" checkbox option be included on the import screen, whereby subscriber fields are updated should the checkbox be checked.

Thanks

Comments

  • +1

    i have a large database that i want to import with, there are many duplicated fields, i would love for sendy to be able to merge the data together.

    I would also like to run a 'update your details' campaign for users, where they would refill in the signup form; this would then update the data in the database. Currently this will not accept the new data.

  • edited November 2013

    I had a similar issue because of how we receive our data, so I re-wrote the import csv script (the cron job). Here are some things you have to be aware of with this code:

    NOTE: This is only for doing csv imports. It has nothing to do with the subscribe API, the API already has the functionality to update fields.

    1. Use at your own risk! I cannot guarantee this code will work in all circumstances. If you want to use it, first run it on a test environment and make changes if necessary in your situation. This code may have bugs!!
    2. I wouldn't recommend using this on csv's larger than 50k rows. It can use a lot of php memory, I'm testing with 50k line csv's and 12 custom fields and it uses about 150MB of memory. Make sure you update your max memory setting in your php.ini to accommodate for this.
    3. Save this as a new file in Sendy's root folder and name it import-csv-update.php.
    4. This will only work if you have the import cron enabled.
    5. You must change the regular import cron to point to the new import-csv-update.php instead of import-csv.php.
    6. There is no need to do anything except upload your csv's, you don't have to upload the files through the web interface (but you can if you want). Just upload your csv's to the uploads/csvs folder and make sure you rename the file using this format: {app_id}-{list_id}-{part_number_optional}.csv. So if your list id is 50, then name the file: 1-50.csv, if you had to split the list up into segments then name the files: 1-50-1.csv, 1-50-2.csv, 1-50-3.csv, etc. If you are uploading through the web interface then you don't need to worry about the naming.

    If you have suggestions or question I'll try to help, I'm still a novice php programmer but I've tried my best with what I have.

    Here is the code for import-csv-update.csv: http://privatepaste.com/d1dfaad664

    EDIT: There was a bug in the previous code that sometimes cut off the last letter of the last custom field, I have fixed the code in the above link.

  • Here is updated code: http://privatepaste.com/7605a6d75f

    The original one was wasting memory by loading the entire parsed csv object into memory even if it didn't need to. This is happening with the standard import script too.

  • +1. Need the ability to update records based on import csv

  • +1 for ability to update records with new imported csv OR an update form, like the Subscribe form.

  • +1 for ability to update records with new imported csv

    john, thanks for sharing your code.... to bad that the privatepaste website is down !

  • Can someone repost the code since privatepaste links are not working? Would love this feature - do we need to remove all users and re-import them thus losing all the bounces etc. for them?

  • +1 for this functionality...

  • No updates on this? I have a list of about 80 000 subscribers, one of the custom fields whether or not the user has an active paid subscription or not, and the date it expires.

    Currently there is no way to update the fields, if i re-import an updated CSV it does not change the details if the email is already in the list.

  • +1 this could be very useful

  • +1, can someone re-upload John's code?

  • edited September 2017

    I had to update custom fields for a rather large list so I did something like this for myself. I've added a link to the code at the bottom of this post. I modified my original import-csv.php file, but it's probably smarter for you to save this file with another name (import-csv-update.php as John did) and then change your cron job to run that instead.

    Few things to note:-
    1 - This will only work for CSV imports with CRON enabled.
    2 - I have not thoroughly tested this, but it works on my lists. You should either run it on a test environment, or on a couple of subscribers first to ensure that it works before updating your entire list. Back up your subscribers table before doing it if possible.
    3 - This will only update the custom fields. Updating the name would require more changes and I didn't need to do this for my lists.

    Taking the remaining steps from John's post since those stay the same:-
    1 Save this as a new file in Sendy's root folder and name it import-csv-update.php.
    2 - This will only work if you have the import cron enabled.
    3 - You must change the regular import cron to point to the new import-csv-update.php instead of import-csv.php.

    Here's the code: https://pastebin.com/ctdsDm62

  • This post originally started in 2013 and I am now facing the same issue. I am using latest version and it looks like this issue never got addressed by dev team at all.

    From time to time, I import list of email addresses. I need UPDATE function if email addresses are existed to update custom fields.

    I used code above by Rahul and it seems like this code only doing the UPDATE but not APPEND to record.

    APPEND to record is needed.

  • So I looked in Rahul's code and I was able to make one little change and now it is working to APPEND the record instead UPDATE the record.

    Line 273
    Delete this:
    $q3 = 'UPDATE '.$databasetable.' SET custom_fields = "'.substr($custom_fields_value, 0, -3).'" WHERE id = '.$inserted_id;

    Replace with this
    $q3 = 'UPDATE '.$databasetable.' SET custom_fields = concat("'.substr($custom_fields_value, 0, -3).'") WHERE id = '.$inserted_id;

  • Is this solution still valid in v3? What is the simplest way to bulk update contact custom fields?

  • edited November 2017

    +1 for bulk update via csv import. @Ben ?

  • +1 for ability to update fields with new imported csv

  • +1: would love to be able to update subscriber info by csv import

  • +1 for this - it would seem to be an essential feature...

  • Ditto to the above - this would be very useful.

    An earlier comment said that the API supports this though, which I can't seem to find.

  • edited June 2019

    +1. We really need the ability to update existing custom fields. Currently if the email already exists, the "/subscribe" API doesn't update the custom fields. Please advise.

    Actually the "/subscribe" does update the custom fields but there is a bug that caused me to think otherwise. I will document the bug in a different thread instead.

    Thanks.

  • +1 Please! This is really crucial to have!

  • has sendy now developed a update function? Very crucial to be able to do it on the interface, not all of us are developers :)

  • sorry i think there has been an update for this - just trying to get it to work

  • same for me : even if ben is saying that it should now work, I cannot make it work: the customs fields are simply not updated when I import a csv file. It says at the end "Already exists" and the update is not done. how may we make that work ?

Sign In or Register to comment.