douxinghuai3150 2013-12-10 23:17 采纳率: 0%
浏览 111
已采纳

将ASCII文件解析为MySQL表

For a project, I need to get some word definitions in a database. All the definitions can be found on multiple DB files, but the DB files that I got are for a C language program and are in the form of ASCII (I believe). I need to somehow phrase thorough the files, line by line add the data into a MySQL database.

I would prefer using PHP and/or MySQL.

I tried writing a PHP script to go through and do it, but it timed-out and is intensive on my system and in most cases don't complete.

I heard about LOAD DATA INFILE from MySQL but have no clue how to use it with this.

The file names change for each file and do not have a specific extension, however, all of them can be read from a text file, and I am sure they are all the same in terms of content.

I uploaded the contents of one file here.

You can see that some lines are useless, but the lines starting with { are good and the pattern is essentially the first word is the dictionary term, and the content within () are the definitions. The parts within the "" are sample sentences.

All I need to extract are the terms, definitions and sentences.

The definitions are provided by Princeton University and the license is open source (and I will be crediting them).

  • 写回答

1条回答 默认 最新

  • duanjie5570 2013-12-10 23:34
    关注

    Unless you want to reinvent the wheel I would go with something like wordnet2sql. It will output an SQL script that you can use to create your MySQL tables.

    You can find the database specifications on princeton's website.

    LOAD DATA is useful for csv files but not so much for special database formats.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口