@@ -63,7 +63,7 @@ mutable struct ReadStatDataFrame
63
63
measures:: Vector{Cint}
64
64
alignments:: Vector{Cint}
65
65
val_label_keys:: Vector{String}
66
- val_label_dict:: Dict{String, Dict{Any,String}}
66
+ val_label_dict:: Dict{String,Dict{Any,String}}
67
67
rows:: Int
68
68
columns:: Int
69
69
filelabel:: String
@@ -72,9 +72,9 @@ mutable struct ReadStatDataFrame
72
72
types_as_int:: Vector{Cint}
73
73
hasmissings:: Vector{Bool}
74
74
75
- ReadStatDataFrame () =
75
+ ReadStatDataFrame () =
76
76
new (Any[], Symbol[], DataType[], String[], String[], Csize_t[], Cint[], Cint[],
77
- String[], Dict {String, Dict{Any,String}} (), 0 , 0 , " " , Dates. unix2datetime (0 ), 0 , Cint[], Bool[])
77
+ String[], Dict {String,Dict{Any,String}} (), 0 , 0 , " " , Dates. unix2datetime (0 ), 0 , Cint[], Bool[])
78
78
end
79
79
80
80
include (" C_interface.jl" )
@@ -139,7 +139,7 @@ get_measure(variable::Ptr{Nothing}) = readstat_variable_get_measure(variable)
139
139
140
140
get_alignment (variable:: Ptr{Nothing} ) = readstat_variable_get_measure (variable)
141
141
142
- function handle_variable! (var_index:: Cint , variable:: Ptr{Nothing} ,
142
+ function handle_variable! (var_index:: Cint , variable:: Ptr{Nothing} ,
143
143
val_label:: Cstring , ds_ptr:: Ptr{ReadStatDataFrame} )
144
144
col = var_index + 1
145
145
ds = unsafe_pointer_to_objref (ds_ptr):: ReadStatDataFrame
@@ -158,7 +158,7 @@ function handle_variable!(var_index::Cint, variable::Ptr{Nothing},
158
158
push! (ds. storagewidths, get_storagewidth (variable))
159
159
push! (ds. measures, get_measure (variable))
160
160
push! (ds. alignments, get_alignment (variable))
161
-
161
+
162
162
return Cint (0 )
163
163
end
164
164
@@ -191,55 +191,55 @@ function handle_value!(obs_index::Cint, variable::Ptr{Nothing},
191
191
readstat_value_is_missing (value, C_NULL )
192
192
end
193
193
194
- if type_as_int== READSTAT_TYPE_DOUBLE
194
+ if type_as_int == READSTAT_TYPE_DOUBLE
195
195
col_float64 = data[var_index]:: DataValueVector{Float64}
196
196
197
197
if ismissing
198
198
DataValues. unsafe_setindex_isna! (col_float64, true , obs_index + 1 )
199
199
else
200
200
readfield! (col_float64, obs_index + 1 , value)
201
201
end
202
- elseif type_as_int== READSTAT_TYPE_INT32
202
+ elseif type_as_int == READSTAT_TYPE_INT32
203
203
col_int32 = data[var_index]:: DataValueVector{Int32}
204
204
205
205
if ismissing
206
206
DataValues. unsafe_setindex_isna! (col_int32, true , obs_index + 1 )
207
207
else
208
208
readfield! (col_int32, obs_index + 1 , value)
209
209
end
210
- elseif type_as_int== READSTAT_TYPE_STRING
210
+ elseif type_as_int == READSTAT_TYPE_STRING
211
211
col_string = data[var_index]:: DataValueVector{String}
212
212
213
213
if ismissing
214
214
DataValues. unsafe_setindex_isna! (col_string, true , obs_index + 1 )
215
215
else
216
216
readfield! (col_string, obs_index + 1 , value)
217
217
end
218
- elseif type_as_int== READSTAT_TYPE_CHAR
218
+ elseif type_as_int == READSTAT_TYPE_CHAR
219
219
col_int8 = data[var_index]:: DataValueVector{Int8}
220
220
221
221
if ismissing
222
222
DataValues. unsafe_setindex_isna! (col_int8, true , obs_index + 1 )
223
223
else
224
224
readfield! (col_int8, obs_index + 1 , value)
225
225
end
226
- elseif type_as_int== READSTAT_TYPE_INT16
226
+ elseif type_as_int == READSTAT_TYPE_INT16
227
227
col_int16 = data[var_index]:: DataValueVector{Int16}
228
228
229
229
if ismissing
230
230
DataValues. unsafe_setindex_isna! (col_int16, true , obs_index + 1 )
231
231
else
232
232
readfield! (col_int16, obs_index + 1 , value)
233
233
end
234
- elseif type_as_int== READSTAT_TYPE_FLOAT
234
+ elseif type_as_int == READSTAT_TYPE_FLOAT
235
235
col_float32 = data[var_index]:: DataValueVector{Float32}
236
236
237
237
if ismissing
238
238
DataValues. unsafe_setindex_isna! (col_float32, true , obs_index + 1 )
239
239
else
240
240
readfield! (col_float32, obs_index + 1 , value)
241
241
end
242
- else
242
+ else
243
243
col_untyped = data[var_index]
244
244
245
245
if ismissing
@@ -284,7 +284,7 @@ function handle_value_label!(val_labels::Cstring, value::Value, label::Cstring,
284
284
ds = unsafe_pointer_to_objref (ds_ptr)
285
285
dict = get! (ds. val_label_dict, unsafe_string (val_labels), Dict {Any,String} ())
286
286
dict[as_native (value)] = unsafe_string (label)
287
-
287
+
288
288
return Cint (0 )
289
289
end
290
290
@@ -311,7 +311,7 @@ function Parser()
311
311
ccall ((:readstat_set_value_handler , libreadstat), Int, (Ptr{Nothing}, Ptr{Nothing}), parser, val_fxn)
312
312
ccall ((:readstat_set_value_label_handler , libreadstat), Int, (Ptr{Nothing}, Ptr{Nothing}), parser, label_fxn)
313
313
return parser
314
- end
314
+ end
315
315
316
316
function parse_data_file! (ds:: ReadStatDataFrame , parser:: Ptr{Nothing} , filename:: AbstractString , filetype:: Val )
317
317
retval = readstat_parse (filename, filetype, parser, ds)
@@ -324,4 +324,4 @@ read_sav(filename::AbstractString) = read_data_file(filename, Val(:sav))
324
324
read_por (filename:: AbstractString ) = read_data_file (filename, Val (:por ))
325
325
read_sas7bdat (filename:: AbstractString ) = read_data_file (filename, Val (:sas7bdat ))
326
326
327
- end # module ReadStat
327
+ end # module ReadStat
0 commit comments