View Full Version : Need help parsing data
12-10-2009, 08:29 PM
Anyone that can help on this one it would be greatly appreciated...
I need to make a form parses a result from column 1 of txt/csv file that has 7 columns. Column 1 is pay, column 2-7 are how many and the associated rows are the answers. In short
1 2 3 4 5 6
700 50 55 62 75 80 99
if (pay <=700 && widgets = 2)
elseif (pay <=700 && widgets = 1)
is this doable and is it the easiest way to accomplish this?
12-11-2009, 12:51 AM
Not to ask a silly question, but... How are you getting the data from that file into the HTML page for JS to parse?
Are you using xmlhttp and getting it all in a big responseText string?
And what is the *specific* format of the file? You say CSV, so is it really commas? Is it commas and quotes?
12-11-2009, 04:12 AM
it can be a comma file or an excel file. The input would come from the user ie: enter your pay.... take that input and run it against the table(file) and then ask the need of 1 to 6 and that produces the number from the table ( kinda like parsing the tax table if you will ...
the above is the concept. would this be easier to build arrays for each possibility? 1000 and 1 = $$ 1000 and 2 = $$ etc?
12-11-2009, 08:31 AM
Oh. you definitely want it to be done via arrays.
But you have to parse the file to create the data elements that you will put into the arrays (well, probably one array...an array of objects).
So what is it you need help with??? If it's parsing the file, then you have to show some examples of the actual lines in the file.
I would think that, after you have parsed the data, the code to scan the array for the match on user input is trivial. A handful of lines.
12-11-2009, 07:32 PM
Maybe this is easier...
How do I accomplish a drop down populated with possible pay (dollar amounts since they have to round up anyways) and another drop down that has the number 1 -6 and based on the two combined it produces the amount owed. So 1000 dollars and claiming 1 is x 1000 dollars claiming 2 is x
That was I just populate what would be in the table into an array of values right?
12-11-2009, 09:17 PM
OH! Income tax.
Income vs. number of deductions produces how much tax is owed.
Yeah, you could use dropdowns, but you still need the "lookup table".
You surely don't want to do this as a mass of "if" tests.
Creating the array--however you do it--is the first step. And parsing a CSV file is a fine way to create the array. It has the huge advantage that all you have to do to change things is drop in a new CSV file.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.