python config file json datatypes
import pandas as pd
import json
import numpy as np
# Create a file (csv) for test purposes
data = '''\
3,10,3.5,abc
3,010,3,bcd'''
file = io.StringIO(data)
# Create a file (json) for test purposes
json_data = '''\
{
"header":[
["field1","int16"],
["field2","float32"],
["field3","float64"],
["field4","str"]]
}'''
# Load json to dictionary
json_d = json.loads(json_data)
# Fetch field names and dtypes
names = [i[0] for i in json_d['header']]
dtype = dict(json_d['header'])
# Now use pandas to read the whole thing to a dataframe
df = pd.read_csv(file,header=None,names=names,dtype=dtype)
# Output as dict (this can be passed to a json file with json.dump())
df.to_dict('r')
Also in JavaScript:
- javascript console.log
- how to use the match function in javascript for regex
- node js how to basic auth to specific urk
- react native flexbox 2 columns 1 fixed width
- Javascript remove array item by value
- react three fiber
- javascript setattribute onclick function with parameters
- how to delete object property of array javascript
- nuxtjs http multiple proxy
- sort data according to date in js
- double click on element using javascript
- sql server import json
- jquery select element with data
- jest async test fetch api
- how to scroll down to the bottom of a div using javascript
- hot to start cypress
- react-native-screens
- includes()
- how to pass dynamic string in string javascript
- javascript ascending and descending
- how to change css with js
- copy link to clipboard
- invalid left-hand side in assignment
- refresh javascript using require