-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add import CSV Command for GMail export #60
Conversation
There was an issue if data wasn't complete, I fixed it so it won't set as empty strings so the database will get NULLs as expected. |
Thanks so much @mkaz Can you indicate here how to get this CSV from Google? I'll update the README. |
@djaiss - sure thing, I was going to make an animated GIF Screenshot, but too difficult with obscuring data.
That will save the file to your system, likely in ~/Downloads/google.csv You can then run it on the command-line using Replace 3 with your user id for the account you want to import to, I just peeked in the database to get this. |
Thanks so much. I'll take care of it tomorrow - it's too late for me now after this incredible day, but I truly appreciate the help here! |
@djaiss - great tool, thanks for building and open sourcing it. I'm glad to help out. |
Adds a check to see if First, Middle, or Last name is set and doesn't import if not set. You can't click into a Contact without a name, so probably not worth importing. Also adds output for how many records imported
Added some comments. |
app/Console/Commands/ImportCSV.php
Outdated
$contact = new Contact(); | ||
$contact->account_id = $user->id; | ||
|
||
if ( ! empty( $data[1] ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the first check should be to verify that either $data[0]
or $data[1]
contains a value (Name or given name) because these are the only data that we need to import. If we don't have one of these two values, we can't import the row, period (a contact without a name won't work in the current UI).
Can you make this check? Thanks a lot!
app/Console/Commands/ImportCSV.php
Outdated
} | ||
|
||
// gender required - default to female | ||
$contact->gender = ( substr($data[15], 0, 1 ) == 'm' ) ? 'male' : 'female'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed that today. You can now default to none
.
Removed gender import, there is no way to set this in Gmail interface and from what I can tell the field has no data and now is not required.
@djaiss updated with requests 👍 |
@mkaz thanks! I've tried it but all the contacts that I import are empty. Instead of blank I should at least get a firstname... Any idea why? I took the CSV from Google Contact using the instructions you've provided. |
Why do we need to search for a users id if we could also use the email address to identify a user for linking the imported data? |
Wouldn't it be better to have a way to import and export vcards instead of limiting it to just google contacts? Not all providers use the same extended syntax for non-standard fields (such as custom labels), but standard fields shouldn't be an issue. |
This was a quick and simple way to import some data in a format that I had it in - if it works for you then great. Ideally, an importer that can handle any format would be great with a front-end and not having to look up users or use the command-line. |
Then why not trigger this import via the UI? |
@mkaz do you know why I got these errors? |
This pull request adds a command to import vcards (similar to #60 ). Usage: php artisan import:vcard {user: User's email address} {path: Path to a .vcf file} The command checks whether an email already exists, so duplicates shouldn't be an issue.
@djaiss I double checked my process and all worked fine for me. I'm not sure if Google exports them in different orders and uses the header to determine which is which. My implementation assumed that it was the same fixed order for every export, which would make sense. If you import your csv file into Excel you can see which column maps to which field |
This pull request has been automatically locked since there |
Adds a Laravel Command to import a Google CSV file, one exported from GMail.
Usage:
php artisan import:csv USER FILE
You will need to look up your user id and import, if you create a new account it is most likely 3. So for me I created a new user and downloaded the file as
google.csv
so the command is:php artisan import:csv 3 google.csv
I also recommend merging any duplicates on Google/Gmail because there are data constraints on duplicate emails.