使用 JavaScript 从制表符分隔的文件中提取数据

发布于 2024-09-16 23:58:45 字数 349 浏览 1 评论 0原文

我正在尝试从制表符分隔的数据文件中提取数据(在某些部分),而且看起来确实很麻烦(我真的希望他们可以将其进行 CSV 编辑)。

数据如下:

http://www.fededirectory.frb.org/FedACHdir.txt

这是格式描述:

www.fededirectory.frb.org/format_ACH.cfm

我想提取此数据并将其存储在服务器端 javascript (ASP) 的数据库中。有什么想法吗?

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 like to extract this data and store it in a database with serverside javascript, (ASP). Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

昔日梦未散 2024-09-23 23:58:45

您的文件不是制表符分隔...它是位置分隔

要使用 javascript 处理文件,该文件必须位于同一服务器上并且可通过 HTTP 访问。

如果您需要将文件上传到某个服务器,服务器端语言需要根据您的 布局文件

为了提取它...您必须执行类似以下操作:

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());

并为文件中的每一行迭代该代码。

在伪代码中:

for (Line line in File)  {
  // do the code above
}

注意:使用 JavaScript 处理该文件会很痛苦,我建议在应用程序的服务器端执行此操作。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文