Form Filling from CSV with Line Breaks

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
macrohelp
Posts: 1
Joined: Mon Jul 23, 2018 7:07 pm

Form Filling from CSV with Line Breaks

Post by macrohelp » Mon Jul 23, 2018 7:09 pm

Is it possible to include line breaks when inputting from a CSV file? I've tried everything but it seems to truncate the line breaks.
User avatar
JamesBassdrop
Posts: 7
Joined: Sun Jul 29, 2018 8:51 pm
Location: Canada
Contact:

Re: Form Filling from CSV with Line Breaks

Post by JamesBassdrop » Wed Aug 01, 2018 8:44 pm

macrohelp wrote:Is it possible to include line breaks when inputting from a CSV file? I've tried everything but it seems to truncate the line breaks.
Hey macrohelp,

Similar to how spaces need to be replaced with <SP>, to include line breaks you'll likely need to replace \r\n, \r, and \n with <BR>:

\r = carriage return
\n = line feed
\r\n = often used in preference to \n as it displays properly on both Windows and Unix/Linux

To avoid the possibility of ending up with duplicate line breaks, \r\n needs to be replaced before \r and \n.

If using a .js (javascript) script, and assuming you've already extracted {{COL1}} as a variable called myVar:

Code: Select all

myVar.replace(/(?:\r\n|\r|\n)/g, "<BR>");   // Replaces \r\n, \r\, \n with <BR>
myVar.replace(/ /g, "<SP>");                // Replaces spaces with <SP>
Or, if using an .iim (pure iMacros) script, something like this should do the trick (again, for {{COL1}}):

Code: Select all

SET !VAR1 EVAL("var myVar = \"{{!COL1}}\"; myVar.replace(/(?:\\r\\n|\\r|\\n)/g, \"<BR>\"); myVar.replace(/ /g, \"<SP>\"); myVar;");
(Note: I haven't specifically tested the above code, but have successfully included line breaks from a CSV file by using this method in the past.)

Cheers, hope this helps — please let us know how it works out!

(Also, just an FYI for future reference: it helps to include your iMacros/browser/OS versions + example code when posing questions to get a response.)
iMacros for Firefox v8.9.7 | Firefox 56.0.2, Firefox 52 ESR, Pale Moon 27.9.4
I compare performance using all 3 browsers while troubleshooting but there's rarely a discernible difference. [Installed on PM using "Moon Tester Tool" add-on]
chivracq
Posts: 8786
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Form Filling from CSV with Line Breaks

Post by chivracq » Wed Aug 01, 2018 10:12 pm

JamesBassdrop wrote:
macrohelp wrote:Is it possible to include line breaks when inputting from a CSV file? I've tried everything but it seems to truncate the line breaks.
Hey macrohelp,

Similar to how spaces need to be replaced with <SP>, to include line breaks you'll likely need to replace \r\n, \r, and \n with <BR>:

\r = carriage return
\n = line feed
\r\n = often used in preference to \n as it displays properly on both Windows and Unix/Linux

To avoid the possibility of ending up with duplicate line breaks, \r\n needs to be replaced before \r and \n.

If using a .js (javascript) script, and assuming you've already extracted {{COL1}} as a variable called myVar:

Code: Select all

myVar.replace(/(?:\r\n|\r|\n)/g, "<BR>");   // Replaces \r\n, \r\, \n with <BR>
myVar.replace(/ /g, "<SP>");                // Replaces spaces with <SP>
Or, if using an .iim (pure iMacros) script, something like this should do the trick (again, for {{COL1}}):

Code: Select all

SET !VAR1 EVAL("var myVar = \"{{!COL1}}\"; myVar.replace(/(?:\\r\\n|\\r|\\n)/g, \"<BR>\"); myVar.replace(/ /g, \"<SP>\"); myVar;");
(Note: I haven't specifically tested the above code, but have successfully included line breaks from a CSV file by using this method in the past.)

Cheers, hope this helps — please let us know how it works out!

(Also, just an FYI for future reference: it helps to include your iMacros/browser/OS versions + example code when posing questions to get a response.)
JamesBassdrop wrote:(Also, just an FYI for future reference: it helps to include your iMacros/browser/OS versions + example code when posing questions to get a response.)
YEEEEP...!, exactly....! :wink:
(Reason why I didn't react to this "Low Quality" Thread/OP, even if the Qt was a bit "interesting" indeed...)
Typo btw: "posing" => "posting"... :wink:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
User avatar
JamesBassdrop
Posts: 7
Joined: Sun Jul 29, 2018 8:51 pm
Location: Canada
Contact:

Re: Form Filling from CSV with Line Breaks

Post by JamesBassdrop » Thu Aug 02, 2018 1:53 am

chivracq wrote:Typo btw: "posing" => "posting"... :wink:
Not a typo...
verb (used with object), posed, pos·ing
5. to assert, state, or put forward:
That poses a difficult problem.
But both would work here :lol:
iMacros for Firefox v8.9.7 | Firefox 56.0.2, Firefox 52 ESR, Pale Moon 27.9.4
I compare performance using all 3 browsers while troubleshooting but there's rarely a discernible difference. [Installed on PM using "Moon Tester Tool" add-on]
chivracq
Posts: 8786
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Form Filling from CSV with Line Breaks

Post by chivracq » Thu Aug 02, 2018 3:47 am

JamesBassdrop wrote:
chivracq wrote:Typo btw: "posing" => "posting"... :wink:
Not a typo...
Pfff, of course it's typo...! :roll: , grrr...!, OK, let me check again...;...:
JamesBassdrop wrote:(Also, just an FYI for future reference: it helps to include your iMacros/browser/OS versions + example code when posing questions to get a response.)
=> Nope, sorry, "posing questions" is definitely no correct English, yeah well, grammatically maybe, but not for the "Meaning"...
Yep in French/Canadian we say "poser une Qt", but not in ENG..., "something is posing a posing a problem", OK...
Hum, oops, OK, you seem to be right as well indeed, but I "sense" a different meaning, it's more a subject/argument that will be posing a Qt = leading to a Qt, leading to some discussion/debate, but it sounds "strange" to me in the Context of a (Tech) Forum, there we (Users) post Qt's..., the "Content" could be posing a Qt, but not the User itself... But OK, never mind, I honestly thought you had made a Typo... :wink:

Your IP is btw "a bit dirty" for Spam, @JBD, you may want to "clean" it... :wink:
JamesBassdrop wrote:
verb (used with object), posed, pos·ing
5. to assert, state, or put forward:
That poses a difficult problem.
But both would work here :lol:
Yep, correct Use of "to pose" (against "to post")...! :wink:

I didn't dig at all into the Thread, waiting for @OP to post their FCI + Script...
OK, I still might if they still do so..., and follow up of course... :roll:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
User avatar
JamesBassdrop
Posts: 7
Joined: Sun Jul 29, 2018 8:51 pm
Location: Canada
Contact:

Re: Form Filling from CSV with Line Breaks

Post by JamesBassdrop » Thu Aug 02, 2018 5:07 pm

chivracq wrote:=> Nope, sorry, "posing questions" is definitely no correct English, yeah well, grammatically maybe, but not for the "Meaning"...
Perhaps "posting" may have been a better fit, but I must maintain that "posing" is correct for both meaning and grammar :lol:
Longman Dictionary of Contemporary English wrote:pose a question
to ask a question, especially one that needs to be carefully thought about
• In her book she poses the question ‘How much do we need to be happy?’.
• He survived the surgery, and I cautiously began to pose questions.
• Yet these two enemies are also enemies of each other, which poses a question.
• That poses a question about their very nature.
• Simply put, eVote lets people pose questions and conduct votes using e-mail.
• It is open to the House to ask for reports, and it can pose questions at any time.
• Olajuwon stopped by to visit and pose a question: Could Pond help him get to college in the United States?
• In their minds, buying a gown poses questions more complicated than chiffon or lace.
• The magazine posed a list of questions to each of the candidates.
Dictionary.com wrote:pose · verb
(transitive) to put forward, ask, or assert
to pose a question
Cambridge English Dictionary wrote:pose · verb (ASK)
• to ask a question, especially in a formal situation such as a meeting
Can we go back to the question that Helena posed earlier?
But aaanyways (intentional typo), moving on... :lol:
chivracq wrote:Your IP is btw "a bit dirty" for Spam, @JBD, you may want to "clean" it... :wink:
My IP address is? Hmm, interesting... that's news to me! Where does one go to check this? I wouldn't mind checking my web server's IP address too. Either way, thanks for the heads up! :)

Cheers,
J
iMacros for Firefox v8.9.7 | Firefox 56.0.2, Firefox 52 ESR, Pale Moon 27.9.4
I compare performance using all 3 browsers while troubleshooting but there's rarely a discernible difference. [Installed on PM using "Moon Tester Tool" add-on]
Post Reply