| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3173 人关注过本帖
标题:依据源csv表格各列数据拆分后生成两个新表格,恳请老师帮助!
只看楼主 加入收藏
BCCN0769
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2021-9-11
收藏
 问题点数:0 回复次数:1 
依据源csv表格各列数据拆分后生成两个新表格,恳请老师帮助!
恳请老师出手帮助,谢谢!
附上单支的源数据及拆分后生成的两个例表
链接:  https://pan.baidu.com/s/1Vge-i2-jxMM3m7QRgCSdXg   提取码:   htrp  

每天有4500多个表格,
文件夹20210901,文件夹下有
000001.csv
000002.csv
000004.csv
000007.csv
600000.csv
600001.csv
.........
文件夹20210902,文件夹下有
000001.csv
000002.csv
000004.csv
000007.csv
600000.csv
600001.csv
.........
文件夹20210903,文件夹下有
000001.csv
000002.csv
000004.csv
000007.csv
600000.csv
600001.csv
.........
需要按文件夹日期生成新的两个文件夹
文件夹20210901买,文件夹下有
000001.csv
000002.csv
000004.csv
000007.csv
600000.csv
600001.csv
.........
文件夹20210901卖,文件夹下有
000001.csv
000002.csv
000004.csv
000007.csv
600000.csv
600001.csv
.........
..............................

源csv表格格式内容:
序号                时间                   价格               成交                委卖量                委买量          方向         委卖ID              委卖价        委买ID                委买价               
1                09:25:00                18.89                100                100                100                B                1                17.1                1                20.9               
2                09:25:00                18.89                300                300                3600                B                2                17.1                2                20.9               
3                09:25:00                18.89                100                100                3600                B                3                17.1                2                20.9               
4                09:25:00                18.89                100                100                3600                B                4                17.1                2                20.9               
5                09:25:00                18.89                100                100                3600                B                5                17.1                2                20.9               
6                09:25:00                18.89                100                100                3600                B                6                17.1                2                20.9               
7                09:25:00                18.89                200                200                3600                B                7                17.1                2                20.9               
8                09:25:00                18.89                500                500                3600                B                8                17.1                2                20.9               
9                09:25:00                18.89                2200                2200                3600                B                9                17.1                2                20.9               
10                09:25:00                18.89                100                200                100                B                10                17.1                10                20.9               
11                09:25:00                18.89                100                200                100                S                10                17.1                11                20.84               
12                09:25:00                18.89                100                300                100                S                12                17.1                12                20               
13                09:25:00                18.89                200                300                2500                S                12                17.1                13                19.95               
14                09:25:00                18.89                100                100                2500                S                14                17.1                13                19.95               
15                09:25:00                18.89                100                100                2500                S                15                17.1                13                19.95               
16                09:25:00                18.89                200                200                2500                S                16                17.1                13                19.95               
17                09:25:00                18.89                800                800                2500                S                17                17.1                13                19.95               
18                09:25:00                18.89                100                100                2500                S                18                17.1                13                19.95               
19                09:25:00                18.89                1000                3300                2500                S                19                17.1                13                19.95               
20                09:25:00                18.89                2300                3300                19100                S                19                17.1                20                19.95               
21                09:25:00                18.89                200                200                19100                S                21                17.1                20                19.95               
22                09:25:00                18.89                200                200                19100                S                22                17.1                20                19.95               
23                09:25:00                18.89                300                300                19100                S                23                17.1                20                19.95               
      

将这个源数据中的数据按委买ID和委卖ID拆分成两个csv新表格,这两个委托ID中有些是一笔成交,有些是多笔成交,如果是一笔的就直接生成一组,如果是多笔成交就将这多笔成交求和后组成一组,此处的成交是统计成交列中的数值
  委卖ID
ID                           时间            委托手数                  价格          成交金额(万)    成交笔数             主动               
15968                09:48:32                  12                19.35                2.32                1                S               
23793                09:59:07                  8                19.44                1.56                1                S               
32034                10:08:01                  10                19.6                  1.96                1                S               
39541                10:15:15                  8                19.69                1.58                1                S               
47782                10:20:42                  1                19.93                0.2                1                S               
13887                09:45:52                  1                19.24                0.19                1                S               
19631                09:53:36                  39                19.37                7.55                1                S               
27872                10:03:07                  2                19.54                0.39                1                S               
39458                10:15:08                  3                19.7                0.59                1                S               
11806                09:43:14                  2                19.28                0.39                1                S               
31951                10:08:01                  1                19.59                0.2                1                S               
4838                09:35:07                  2                19.18                0.38                1                S               
9725                09:40:46                  100                19.23                19.23                1                S               
19548                09:53:34                  5                19.36                0.97                1                S               
7918                09:38:12                  7                19.13                1.34                3                S               
15885                09:48:27                  30                19.34                5.8                1                S               
23627                09:58:43                  114                19.44                22.16                1                S               
13804                09:45:40                  2                19.2                0.38                1                S               
19465                09:53:31                  3                19.35                0.58                1                S               
27706                10:02:56                  2                19.54                0.39                1                S               
11723                09:43:09                  2                19.28                0.39                1                S               
9642                09:40:43                  10                19.21                1.92                1                S               
3926                09:34:19                  2                19.08                0.38                1                S               
15802                09:48:17                  190                19.33                36.73                1                S               
6836                09:36:53                  152                19.25                29.26                1                S               
11640                09:43:05                  1                19.27                0.19                1                S               
4755                09:35:04                  13                19.16                2.49                1                S               
9559                09:40:30                  2                19.2                0.38                1                S               
7835                09:38:06                  7                19.13                1.34                1                S               
5754                09:35:54                  3                19.2                0.58                1                S               
105952                11:00:33                  11                20.42                2.25                1                S               
9476                09:40:29                  5                19.18                0.96                1                S               
97545                10:52:03                  10                20.17                2.02                2                S               
965                09:30:30                  10                18.86                1.89                1                S               
105620                11:00:24                  5                20.4                1.02                1                S               
1676                09:31:38                  3                18.99                0.57                1                S               
72490                10:34:08                  2                20.25                0.41                1                S               
80731                10:38:19                  18                20.44                3.68                1                S               
88972                10:42:09                  8                20.45                1.64                1                S               
72324                10:34:06                  20                20.23                4.05                1                S               
80565                10:38:12                  20                20.43                4.09                1                S               
4672                09:35:02                  200                19.18                38.36                2                S               
72158                10:34:04                  16                20.2                3.23                6                S               
80399                10:38:10                  50                20.43                10.21                4                S               
60523                10:27:35                  250                20.14                50.35                12                S               
71992                10:33:59                  500                20.2                101.04                23              此处空格表示是B  --买入  #如果能写入B更好       
80233                10:38:07                  10                20.42                2.04                2                S               
96715                10:51:03                  10                20.23                2.02                1                S               


例 委买ID
ID                        时间                委托手数              价格                成交金额(万)        成交笔数           主动               
3775                   09:34:09                  73                19.1                13.94                3                B               
50862                10:22:24                  181                19.99                36.18                2                B               
77393                10:36:52                  659                20.38                134.3                80                B               
102116                10:56:09                  5                20.05                1                1                B               
6919                09:36:56                  14                19.25                2.69                1                B               
23710                09:58:56                  1                19.45                0.19                1                B               
101784                10:55:51                  3                20.03                0.6                1                B               
1101                09:30:38                  14                18.89                2.64                1                B               
27789                10:03:07                  5                19.53                0.98                1                B               
58854                10:26:33                  23                20.09                4.62                4                B               
68654                10:31:46                  5                20.34                1.02                3                B               
76895                10:36:45                  2                20.35                0.41                1                B               
101618              10:55:31                  130                20.04                26.05        17                B               
1871                 09:31:58                  52                19.81                9.89                5                B               
15885                09:48:27                  500                19.34                96.7                31         此处空格表示是S  --卖出  #如果能写入S更好               
68488                10:31:39                  2                20.34                0.41                2              此处空格表示是S  --卖出  #如果能写入S更好               
93211                10:47:12                  15                20.22                3.03                1                B               
101452              10:55:20                  100                20.04                20.04        8                B               
33965                10:08:59                  56                19.68                11.02        12                B               
50447                10:22:18                  6                19.99                1.2                1                B               
58688                10:26:25                  2                20.1                      0.4                1                B               
93045                10:47:06                  5                20.21                1.01                2                B               
5837                 09:35:59                  30                19.23                5.77                6                B               
23544                09:58:32                  2                19.43                0.39                1                B               
125                   09:25:00                    34                19.5                  6.42                6               此处空格表示是S  --卖出  #如果能写入S更好
搜索更多相关主题的帖子: 表格 生成 文件夹 csv 拆分 
2021-09-13 18:51
BCCN0769
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2021-9-11
收藏
得分:0 
或者按照下面脚本的方式一列一列输出写个SQL脚本处理,请老师出手帮忙,谢谢!



--数据源格式:TranID int,Time text,Price real,Volume int,SaleOrderVolume int,BuyOrderVolume int,Type text,SaleOrderID int,SaleOrderPrice real,BuyOrderID int,BuyOrderPrice real

create table biao2 as select TranID
                        ,Time as 时间
                        ,Price / 100  as 价格       --单位元
                        ,Volume as 成交             --单位股
                        ,SaleOrderVolume as 委卖量  --单位股
                        ,BuyOrderVolume as 委买量   --单位股
                        ,Type as 方向
                        ,SaleOrderID as 委卖ID
                        ,SaleOrderPrice / 100 as 委卖价  --单位元
                        ,BuyOrderID as 委买ID
                        ,BuyOrderPrice / 100 as 委买价   --单位元
                        ,SaleOrderPrice * SaleOrderVolume / 100 as  委卖额    --单位元
                        ,BuyOrderPrice * BuyOrderVolume / 100 as  委买额      --单位元
                        ,Volume * Price / 100  as 成交额                    --单位元
                                     from biao;

select sum(成交额)  from (select 委买ID from biao2 group by 委买ID) ;

select sum(成交额)  from (select 委卖ID from biao2 group by 委卖ID) ;

drop table biao;
drop table biao2;
vacuum;
2021-09-14 15:18
快速回复:依据源csv表格各列数据拆分后生成两个新表格,恳请老师帮助!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.033385 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved