23
23
"f5" : np .float32 ,
24
24
"f6" : np .float64 ,
25
25
"b0" : bool
26
- }
26
+ }
27
27
28
- with open (args .input_file , "rb" ) as f :
29
- # f = open("test.fsdaq", "rb")
30
- df = pl .DataFrame ()
28
+ with open (args .input_file , "rb" ) as f :
31
29
batchlen = 0
32
30
data = f .read ()
33
- # print(ascii(data))
34
31
header = ascii (data [:8 ])
35
32
m = np .frombuffer (data [8 :12 ], dtype = np .uint32 , count = 1 )[0 ]
36
33
n = np .frombuffer (data [12 :16 ], dtype = np .uint32 , count = 1 )[0 ]
48
45
colType = data [pos :pos + 2 ].decode ('ascii' )
49
46
colTypes .append ((types_dict [colType ], int ((2 ** int (colType [1 ]))/ 8 * n )))
50
47
pos += 2
51
- # print(colTypes)
52
48
data_left = len (data [pos :])
53
49
len_of_frame = sum ([x [1 ] for x in colTypes ])
54
50
chunks = np .floor (data_left / len_of_frame )
55
51
misc_bytes = (data_left % len_of_frame ) - 8
56
52
print (f"chunks left: { chunks } " )
57
53
print (f"misc bytes left: { misc_bytes } " )
54
+ frames = []
58
55
for i in range (int (chunks )):
59
56
frame_pieces = []
60
57
for i in range (m ):
79
76
frame_piece_series = pl .Series (colTitles [i ], col_bit )
80
77
frame_pieces .append (frame_piece_series )
81
78
pos += col_byte_len
82
- frame_piece = pl .DataFrame (frame_pieces )
83
- # print(frame_pieces)
84
- if df .is_empty ():
85
- df = frame_piece
86
- else :
87
- df = df .vstack (frame_piece )
88
- # print(df)
79
+ frames .append (pl .DataFrame (frame_pieces ))
80
+ df = pl .concat (frames , how = "vertical" )
81
+ # print(df)
89
82
print (f"Stuff Left: { ascii (data [pos :])} " )
90
- df .write_csv (args .output_file )
83
+ df .write_csv (args .output_file )
0 commit comments