質問するログイン新規登録

質問編集履歴

2

;oiuygtf678y9iopkl

2019/01/29 07:10

投稿

heisei_no_saigo
heisei_no_saigo

スコア29

title CHANGED
File without changes
body CHANGED
@@ -1,20 +1,23 @@
1
1
  ```ここに言語を入力
2
- コード
3
2
  if __name__=="__main__":
4
3
  temp = dict()
5
-
6
4
  for file in sorted(glob.glob("a/*.csv")):
7
5
  temp[file] = []
8
6
  with open(file, 'r') as f: #ファイルを読み取りモードで開く
9
7
  for line in f.read().splitlines():
10
8
 
11
9
  line_data_arr = [s for s in line.split(",") if s != ""]
12
- if len(line_data_arr) == 7:
10
+ if len(line_data_arr) == 4:
13
- # print(line_data_arr)
11
+ #print(line_data_arr)
14
12
  temp[file].append(line_data_arr)
15
13
 
16
14
  for file, S in temp.items():
17
15
  #print("{} :\n{}\n".format(file, S))
16
+
17
+ #print(S)
18
+ #print([ [ [e] for e in x ] for x in itertools.chain.from_iterable( temp.values() ) ])
19
+ S=[ [[e] for e in x ] for x in itertools.chain.from_iterable( temp.values() ) ]
20
+ print(S)
18
21
  ```
19
22
  ここで2次元配列の中身を出力するとこまでできてます
20
23
 

1

g字脱字

2019/01/29 07:10

投稿

heisei_no_saigo
heisei_no_saigo

スコア29

title CHANGED
File without changes
body CHANGED
@@ -22,7 +22,7 @@
22
22
  [['10','100','1000','10000'],['11','101','1001','10001']]
23
23
  [['12','102','1002','10002']]
24
24
  [['13','103','1003','10003'],['14','104','1004','10004']]
25
- ですが出力させたいんです
25
+ ですがこう出力させたいんです
26
26
  [[['10'],['100'],['1000'],['10000']]
27
27
  [['11'],['101'],['1001'],['10001']]]
28
28
  [[['12'],['102'],['1002'],['10002']]]