Extracting data from a tab-delimited file with JavaScript
I'm trying to extract data from a data file that's tab-delimited (in some parts), and really seems like it's going to be a headache to work out (I reallw wish they could just have CSV-ed it).
Here's the data:
http://www.fededirectory.frb.org/FedACHdir.txt
Here's the format description:
www.fededirectory.frb.org/format_ACH.cfm
I'd lik开发者_如何学Pythone to extract this data and store it in a database with serverside javascript, (ASP). Any ideas?
Your file is not tab delimited
... it is position delimited
.
To handle the file using javascript
, the file must be on the same server and available via HTTP
.
If you need to upload the file to some server, the server side language need to extract all the data based on your layout file
In order to extract it... you must for example do something like:
String line = "011000015O0110000150020802000000000FEDERAL RESERVE BANK 1000 PEACHTREE ST N.E. ATLANTA GA303094470866234568111 ";
String routingNumber = line.substring(0,8);
String officeCode = line.substring(8,9);
String servicingNumber = line.substring(9,17);
String typeCode = line.substring(17,18);
...
...
...
String filler = line.substring(151,line.length());
And iterate
that code for every line in your file.
In pseudo-code :
for (Line line in File) {
// do the code above
}
Note: Process that file with JavaScript
will be painful I recommend to do it in the server side of your application.
精彩评论