这个文本文件有什么问题?

时间:2011-09-27 10:23:11

标签: mysql file text ansi

我有这个文本文件,它只是一个我从excel复制/粘贴到记事本的列。我需要将这个长列添加到MySQl表中。

  1. 当我保存文本文件时,它表示它不是ANSI格式,因此我应该更改格式
  2. 当我将其插入MySQL列时,未正确插入列,并且在某些行中省略了名称。
  3. 我应该这样:

    • 401_Chr1(应从401开始,col1中的任何行都不应为空)
    • 402_chr2
    • 403_chr3等...

    但我最终得到了那个东西:

    +----------+-----------+-----------+----------------------------------------+
    | col1      | start     | end       | sv_id                                 |
    +----------+-----------+-----------+----------------------------------------+
                 |19697691 | 119698417 | 1
     |402_Chr1 | 119733151 | 119926178 | 2
     |403_Chr1 | 119748355 | 119941691 | 3
                 |21014665 | 121015358 | 4
                 |22795978 | 122800912 | 5
                 |22932211 | 122938556 | 6
                 |23058013 | 123059350 | 7
                 |23099162 | 123107650 | 8
                 |23380132 | 123380895 | 9
                 |23673831 | 123678274 | 10
     |411_Chr1 | 124033638 | 124035798 | 11
     |412_Chr1 | 124033644 | 124035811 | 12
    

    这是我的代码:

      mysql> show create table list;  
      list  | CREATE TABLE `list` (
      `chr` varchar(255) DEFAULT NULL,
      `start` bigint(20) DEFAULT NULL,
      `end` bigint(20) DEFAULT NULL,
       ENGINE=InnoDB DEFAULT CHARSET=utf8 |
    
     mysql> load data local infile 'C:/DB/SV/data/test.txt' into table list;
     Query OK, 2401 rows affected, 4275 warnings (0.05 sec)
     Records: 2401  Deleted: 0  Skipped: 0  Warnings: 0
    
     mysql> delete from list where  sv_id=0;
     Query OK, 2201 rows affected (0.05 sec)
    

    哦,不要介意sv_id列我将其更改为自动递增..无论如何,这里的问题是弄清楚我的test.txt文件和col1的内容。

0 个答案:

没有答案
相关问题