Title
Parse Uploaded text file.
Post
So I created a container. I set up the ability to upload a test file. Now what I want to do is parse the text file. There are some symbols in the text file that can help me define areas. Here is an example:
["DATA1"]
["SYSTEM"]="|Data|h[Store Place]|h|r"
Basically I want to grab the data between the |h[ and ]|h|r
Then I want to dump it in a field in my database.
Does anyone have any idea on how I could do this?
Thanks,
William
Most likely, you'll want to begin your script by finding out how many lines are in the text field, using ValueCount. Then, in the loop that chooses the lines, use a counter Variable to keep track of where you're at. Use the Exit Loop If [$counter = $num_lines] script step. Putting it all together, in simplest form:
Set Error Capture [On]
Set Variable [$num_lines, ValueCount(table::text_field)]
Loop
Set Variable [$counter, $counter+1]
Set Variable [$current_line, GetValue ( table::text_field, $counter )]
Set Variable [$extract,
Let ( [ $start = Position ( $current_line, "|h[", 1, 1 ) + 3; $end = Position ( $current_line, "]h", 1, 1 ) - 1; $length =max ( $end - $start, 0 )];
Middle ( $current_line, $start, $length )
)
]...
do your stuff with the extracted data
...
Exit Loop If [$counter = $num_lines]
End Loop