How do you handle empty .CSV file data?

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

How do you handle empty .CSV file data?

by Copy_paste_coder on Thu Jul 20, 2017 4:13 pm

Using iMacros build 9030808 with Firefox add-on (Firefox version 50.1.0) on WINDOWS 7. Trying to pass data from .CSV to website.
How should I account for optional entries in my .CSV file? For example:

Main dish, Side dish, Drink
burger, fries, coke
fish, chips, orange juice
pizza, , water

In the above example, the Pizza order will throw an error when iMacros tries to insert " " in the listbox. Displays:

Code: Select all
"Entry [] not available [Box has 804 entries], line: 24 (Error code: -924):"


Is there something in iMacros similar to:

Code: Select all
If ({!COL2} is NOT equal to " "), then
   TAG POS=1 TYPE=SELECT FORM=ID:procform ATTR=ID:field_52291 CONTENT=${{!COL2}}
Last edited by Copy_paste_coder on Thu Jul 20, 2017 5:38 pm, edited 3 times in total.
Copy_paste_coder
 
Posts: 3
Joined: Thu Jul 20, 2017 3:54 pm

Re: How do you handle empty .CSV file data?

by chivracq on Thu Jul 20, 2017 4:54 pm

Copy_paste_coder wrote:Using iMacros build 9030808 with Firefox add-on. Trying to pass data from .CSV to website.
How should I account for optional entries in my .CSV file? For example:

Main dish, Side dish, Drink
burger, fries, coke
fish, chips, orange juice
pizza, , water

In the above example, the Pizza order will throw an error when iMacros tries to insert " " in the listbox. Displays:
Code: Select all
"Entry [] not available [Box has 804 entries], line: 24 (Error code: -924):"


Is there something in iMacros similar to:
Code: Select all
If ({!COL2} is NOT equal to " "), then
   TAG POS=1 TYPE=SELECT FORM=ID:procform ATTR=ID:field_52291 CONTENT=${{!COL2}}

FCIM...! :mrgreen: (Read my Sig...)
=> iMacros for FF v9.0.3, FF54...?, OS...?

Hum, RuntimeError you mention is typical for a DDLB (= 'SELECT' HTML Element)...

But yep, several Approaches possible to handle your Scenario, easiest will probably be using 'EVAL()' and/or '!ERRORIGNORE'...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6477
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: How do you handle empty .CSV file data?

by Copy_paste_coder on Thu Jul 20, 2017 5:22 pm

Thanks for the hint, updated original post to include versions.

I did try an EVAL statement after a while of watching Javascript tutorials. Is this close?

Code: Select all
SET !${{!COL2}} EVAL("if (\"${{!COL2}}\" != " ")
   TAG POS=1 TYPE=SELECT FORM=ID:procform ATTR=ID:field_900022 CONTENT=${{!COL2}};
Copy_paste_coder
 
Posts: 3
Joined: Thu Jul 20, 2017 3:54 pm

Re: How do you handle empty .CSV file data?

by chivracq on Thu Jul 20, 2017 6:56 pm

Copy_paste_coder wrote:Thanks for the hint, updated original post to include versions.

I did try an EVAL statement after a while of watching Javascript tutorials. Is this close?

Code: Select all
SET !${{!COL2}} EVAL("if (\"${{!COL2}}\" != " ")
   TAG POS=1 TYPE=SELECT FORM=ID:procform ATTR=ID:field_900022 CONTENT=${{!COL2}};

OK, perfect for FCI:
Using
Code: Select all
iMacros build 9030808 with Firefox add-on (Firefox version 50.1.0) on WINDOWS 7.


OK, "close-close", hum..., not completely, you sound like you have some Programming Background, but I don't recognize from which Prog-Lang, ah-ah...!, but I don't think this kind of Syntax will work with iMacros... :oops:

But try this one first:
Code: Select all
SET !ERRORIGNORE YES
TAG POS=1 TYPE=SELECT FORM=ID:procform ATTR=ID:field_900022 CONTENT=${{!COL2}}

=> If the Content of '!COL2' is "valid" for a "Select by Name", your Statement will select the correct/corresponding Entry in the DDLB, and otherwise it won't do anything... :idea:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6477
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: How do you handle empty .CSV file data?

by chivracq on Thu Jul 20, 2017 7:25 pm

OK, C# Background ah-ah...!, it would help if you provided "everywhere" the same Info:
- iMacros, conditional based on .CSV data
(Now you can add your FCI on SOF as well, ah-ah...! Perfectly legit to ask the same Qt on different Forums but you need to maintain the same "Quality" on all your Threads...)

I'm trying to get iMacros to enter data from a C# generated .CSV file into a webpage. If one of the fields remains blank, iMacros errors out with
Code: Select all
"Entry [] not available [Box has 804 entries], line: 24 (Error code: -924):"


How can I set iMacros to conditionally enter data ONLY if that .CSV column has data in it?

Here's the code:
Code: Select all
TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:procform ATTR=NAME:next
TAG POS=1 TYPE=SELECT FORM=ID:procform ATTR=ID:field_900022 CONTENT=${{!COL11}}


I tried to use an EVAL command, but it didn't work:
Code: Select all
SET !${{!COL11}} EVAL("if (\"${{!COL11}}\" != " ")   
    TAG POS=1 TYPE=INPUT:BUTTON FORM=ID:procform ATTR=NAME:next
    TAG POS=1 TYPE=SELECT FORM=ID:procform ATTR=ID:field_900022 CONTENT=${{!COL11}};


Note: using
Code: Select all
iMacros free firefox add-on & Visual Studio 2015 C#.
I used a space (" ") in the c# program to hold the CSV field (i.e. "data, data, , more data"). It can very well be another character. Thanks

Hum, and that explains the Spaces in your '.CSV' DataSource as I was wondering about those, ah-ah...!

Your '.CSV' looked a bit strange/fake because of those extra Spaces only from Col_2, they would probably get trimmed if you opened your File in Excel/OO for some manual Edit, => I think it's better without those Spaces, and if needed, you can then easily run a Check on the Length of the String, if >0, then you know that your Cell contains some Data...
Hum, and they even "pollute" your Data as well and you need to trim them anyway before you can use '{{!COL2}}' (or '{{!COL11}}') in some 'TAG' Statement, so you make your Task unnecessarily more difficult, I would think...
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6477
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)

Re: How do you handle empty .CSV file data?

by Copy_paste_coder on Fri Jul 21, 2017 5:37 am

OK, C# Background ah-ah...!, it would help if you provided "everywhere" the same Info:
- iMacros, conditional based on .CSV data
(Now you can add your FCI on SOF as well, ah-ah...! Perfectly legit to ask the same Qt on different Forums but you need to maintain the same "Quality" on all your Threads...)


chivracq, you sleuth-y genius!
Code: Select all
SET !ERRORIGNORE YES

worked perfectly. For good form I added:
Code: Select all
SET !ERRORIGNORE NO


I will learn to post better on forums. When I first learned C, the internet wasn't invented. Had to use books. Now I need to work on parsing out multiple entries... hamburger, fries:pickle:cake, cola
Copy_paste_coder
 
Posts: 3
Joined: Thu Jul 20, 2017 3:54 pm

Re: How do you handle empty .CSV file data?

by chivracq on Sat Jul 22, 2017 1:31 pm

Copy_paste_coder wrote:
OK, C# Background ah-ah...!, it would help if you provided "everywhere" the same Info:
- iMacros, conditional based on .CSV data
(Now you can add your FCI on SOF as well, ah-ah...! Perfectly legit to ask the same Qt on different Forums but you need to maintain the same "Quality" on all your Threads...)


chivracq, you sleuth-y genius!
Code: Select all
SET !ERRORIGNORE YES

worked perfectly. For good form I added:
Code: Select all
SET !ERRORIGNORE NO


I will learn to post better on forums. When I first learned C, the internet wasn't invented. Had to use books. Now I need to work on parsing out multiple entries... hamburger, fries:pickle:cake, cola

Hum, FCI not added to your Thread on SOF, and, ah-ah...!, I see that Advanced User on SOF @Shugar has come up with the same Solution as well...
To use SOF "a bit correctly" as well, you need to accept his Solution and to follow up with a mini-Thanks and you can maybe link to this current parallel Thread...

Well, concerning "Now I need to work on parsing out multiple entries... hamburger, fries:pickle:cake, cola...", the Syntax to use is documented as well in the Wiki from the Link I posted about "Select by Name":
In multiple selection menus multiple selection can be achieved by listing indices separated by a colon (:).

Code: Select all
TAG POS=1 TYPE=SELECT FORM=NAME:form1 ATTR=NAME:select1 CONTENT=$Apple:$*berry*:$Peach
TAG POS=1 TYPE=SELECT FORM=NAME:form1 ATTR=NAME:select1 CONTENT=#1:#3:#8


To select all values of a selection use CONTENT=ALL. If you start the macro via iimPlay and select a value that is NOT in the selection then the iimPlay command returns an error code that is the maximum number of lines possible. For an example, please see this forum post: Number of Options in a Select tag.

I actually posted a "creative" Solution in pure '.iim' in that "Number of Options in a Select tag." Thread that @Shugar probably doesn't know, ah-ah...!, and from which I use the same Principle to deal with dynamic ID's... 8)
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
chivracq
 
Posts: 6477
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to General Support & Discussions

Who is online

Users browsing this forum: No registered users and 12 guests

-->