Extracting data from a tab-delimited file with JavaScript - Printable Version +- 0Day Forums (https://zeroday.vip) +-- Forum: Coding (https://zeroday.vip/Forum-Coding) +--- Forum: JScript (https://zeroday.vip/Forum-JScript) +--- Thread: Extracting data from a tab-delimited file with JavaScript (/Thread-Extracting-data-from-a-tab-delimited-file-with-JavaScript) |
Extracting data from a tab-delimited file with JavaScript - dissilient467759 - 07-24-2023 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: [To see links please register here] Here's the format description: [To see links please register here] I'd like to extract this data and store it in a database with serverside javascript, (ASP). Any ideas? RE: Extracting data from a tab-delimited file with JavaScript - serafinajzmug - 07-24-2023 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][1] 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. [1]: [To see links please register here] |