Jump to content

Applescript to import notes from a CSV sometimes stops working


Recommended Posts

I have been using an Appliescript to import notes and tags from a CSV file that I generate from the download option in Google Sheets: http://veritrope.com/code/evernote-csv-and-text-file-importer/

On some CSV files this script has been stopping for me after importing only 14 notes, and hanging. Is there some reason why this script would consistently stop after 14 notes for certain CSV files?

Link to comment
  • Level 5*
6 minutes ago, rmresearch said:

On some CSV files this script has been stopping for me after importing only 14 notes, and hanging. Is there some reason why this script would consistently stop after 14 notes for certain CSV files?

I'd look at your csv file and see if there's something odd at the 14 point.

I doubt it's a size issue; I'm able to process large files.

Link to comment
  • Level 5*
1 hour ago, DTLow said:

I'd look at your csv file and see if there's something odd at the 14 point.

I doubt it's a size issue;

I agree in general, but since 14 were successful, the issue is probably  with the 15th CSV line/record.

1 hour ago, rmresearch said:

On some CSV files this script has been stopping for me after importing only 14 notes, and hanging. Is there some reason why this script would consistently stop after 14 notes for certain CSV files?

if you don't mind posting your CSV file (lines 13-16 should be sufficient), I'll take a look to see if I can spot anything unusual.

But you can also try this:  Does the CSV file open OK in a spreadsheet app like Excel?

Link to comment

Thanks for offering to look at the file, I opened the CSV file and realized that the problem was with quotation marks. If there were quotation marks in the desired title of the note, the script would stop. In the past, the script would turn quotation marks into the HTML code ‚Äô and it wouldn't convert them back, which was not ideal but it would still run. I'm not sure why it has changed its behavior on more recent CSV files. I ran the script on a different CSV file and it created dashes between all the words in the title, so it seems a bit finicky.

I have read that there is an alternative way to turn a Google Sheet or CSV file into Evernote notes, and to assign tags, with an iOS app called workflow.is.  If anyone can explain how that would work, or if there is another good method to go from a Google Sheet or CSV file to Evernote and assign multiple tags, l'd be interested to know. 

It's worth noting that I had tried deleting the first 14 rows of my CSV and running the script again, and it stopped after the 14th note again, so I thought there was some significance to the 14th note. But it turns out that was just a coincidence - the 14th and 28th rows happened to be the only two rows in my sheet that had quotation marks in the titles.

Link to comment
  • Level 5*
2 hours ago, rmresearch said:

Thanks for offering to look at the file, I opened the CSV file and realized that the problem was with quotation marks. If there were quotation marks in the desired title of the note, the script would stop.

I have read that there is an alternative way to turn a Google Sheet or CSV file into Evernote notes, and to assign tags, with an iOS app called workflow.is.  If anyone can explain how that would work, or if there is another good method to go from a Google Sheet or CSV file to Evernote and assign multiple tags, l'd be interested to know.

Glad you identified the issue - you can edit the file and remove the quotes

Honestly, I think you're using the best method to import a csv file
I don't know exactly what the script problem issue is but you should be able to look at the code and fix it.
You could contact Veritrope, but it's really a DIY application

Link to comment
  • Level 5*
4 hours ago, rmresearch said:

Thanks for offering to look at the file, I opened the CSV file and realized that the problem was with quotation marks. If there were quotation marks in the desired title of the note, the script would stop.

Here some ideas (untested) you might try to fix the issue with quotes:

  • Open the CSV file in a text editor, and change all quotes to single-quotes (or other character of your choice)
  • Mod the AppleScript to make the same change BEFORE it parses the line as a CSV line.

If want to mod the Script, here's a function from macosxautomation.com:
AppleScript: Essential Sub-Routines 

One note: To enter a quote as a literal, you have to escape it using a backslash:

-- assume line from file is in sourceLine
set sourceLineClean to my replace_chars(sourceLine, "\"", "'")
Quote

REPLACING CHARACTERS IN A STRING

The following sub-routine can be used to replace specific characters in a string. The sub-routine has three passed parameters: 1) the text to alter, 2) to text to search for, 3) the replacement text

set the message_text to "On Tuesday I told you to have the report ready by next Tuesday."
set the message_text to replace_chars(message_text, "Tuesday", "Friday")
--> Returns: "On Friday I told you to have the report ready by next Friday."

Click to open example in the Script Editor applicationA sub-routine for replacing characters in strings:
 


on replace_chars(this_text, search_string, replacement_string)
 set AppleScript's text item delimiters to the search_string
 set the item_list to every text item of this_text
 set AppleScript's text item delimiters to the replacement_string
 set this_text to the item_list as string
 set AppleScript's text item delimiters to ""
 return this_text
end replace_chars

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...