How to convert JSON file to DXF file using Python? - json

I have a json file with 88476 lines of code, this is the movement of the robot, I need to convert this to dxf format. Code start: "header": {
"mapType": "2D Map",
"mapName": "default_15.12",
"minPos": {
"x": -2.366,
"y": -10.452
},
"maxPos": {
"x": 27.773,
"y": 3.69
Please write the code that will convert all this. Recommend a library for this task.
I tried using the ezdxf library, but it didn't work for me

Related

I'm not able to export the data, fetched from the Database to Excel (.csv) or (xlsx) format in Node.JS

I'm getting the data from database in Json format.
[
{
"name": "Raj",
"age": 20,
"fav-color": "blue"
},
{
"name": "Rahul",
"age": 23,
"fav-color": "green"
},
{
"name": "Vijay",
"age": 21,
"fav-color": "white"
},
]
I want it to put into the Excel file like,
name |age|fav-color
raj | 20| blue
rahul|23 | green
vijay|21 | white
You can use xlsx npm module.
Go here to this package.
Use json to sheet function for generating Excel sheet.
You can use json parser to read the json document and exporting it into an excel file in your desired format using poi package.
I found ExcelJS library was great to address my problem.
the documentation was done very well,
here is the link to ExcelJS

CSV to JSON and add title

I have a csv document:
{
"epsilon_id": 194029423,
"weather": "cloudy",
"temperature": 27
},
{
"epsilon_id": 932856192,
"weather": "sunny",
"temperature": 31
}
I was wondering if there was a tool to make it into valid json where the field epsilon_id is the title for the data.
ex:
{
194029423: {
"weather": "cloudy",
"temperature": 27
},
932856192: {
"weather": "sunny",
"temperature": 31
}
}
I would prefer it to be a program (in whatever language) that I can run because I have 1,000 entries in my test sample and I will have tens of thousands in my final copy.
Any help would be much appreciated!
You are looking at JSON transformation, and ofcourse can be achieved with a custom programming. I can explain you how you can achieve this in Java, but functionally its gonna be the same for any programming of your choice.
Your input json will look like this:
[{
"epsilon_id": 194029423,
"weather": "cloudy",
"temperature": 27
},
{
"epsilon_id": 932856192,
"weather": "sunny",
"temperature": 31
}]
When you parse in java using popular Jackson library, you will get list of object for below class:
class Input
{
#JsonProperty(access = Access.WRITE_ONLY)
String epsilon_id,
String weather,
int temperature
}
Then you create a map object Map<Integer, Input>, populate data like below:
Map<Integer, Input> map = new HashMap<>();
for(Input obj : listOfInputs){
map.put(obj.epsilon_id, obj)
};
Serialize your result map using Jackson again to get your desired output format:
{
194029423: {
"weather": "cloudy",
"temperature": 27
},
932856192: {
"weather": "sunny",
"temperature": 31
}
}
If you are not very familiar with Java & Jackson JSON parsing, I found this tutorial with code sample, which will give you headstart.
import csv, json, os
# rename this file or pass it in as process.argv[2]
# then pipe output into another file. or
with open("./foo.csv") as f:
output = {}
for line in csv.DictReader(f):
key = line.pop("epsilon_id")
if output.has_key(key):
print("Duplicate Id -> {} ".format(key))
output[key] = line
# then pipe this output into another file.
print(json.dumps(output, indent=2))
# or write a file
with open("/tmp/foo.json",'w') as f:
json.dump(output, f)
Python makes it pretty easy : this will detect all types from a csv file.
demo : https://repl.it/#markboyle/UsableIcyFeed

Nodejs Create excel (csv/xlsx) buffer file from json

I am looking for library which will create excel file ( csv and xlsx ) from from json
I have array of objects
var arr=[
{
"name": "Ivy Dickson",
"date": "2013-05-27T11:04:15-07:00",
"number": 10
},
{
"date": "2014-02-07T22:09:58-08:00",
"name": "Walker Lynch",
"number": 2
},
{
"number": 5,
"date": "2013-06-16T05:29:13-07:00",
"name": "Maxwell U. Holden"
},
{
"name": "Courtney Short",
"date": "2014-03-14T07:32:34-07:00",
"number": 6
}
]
and I want to convert it into excel file buffer.
I am not getting which library is best for my condition.
please suggest better library.
You have that package json2xls, it's really easy to use, but it's only for convert json in excel file.
But you have a other package for convert json in csv, it's json2csv.

JSON to generate app dmg

I'm trying to find an automatic way to generate at dmg file with my app inside and a nice looking background and application icon. I have found a an app which generate this called appdmg
https://www.npmjs.com/package/appdmg
My issue is that the json file is not understand and still complaining about a syntax issue.
Any example I found matching my syntax..
{
"title": "myApp",
"icon": "icon.ico",
"background": "banner.png",
"icon-size": 80,
"contents": [
{ "x": 192, "y": 344, "type": "link", "path": "/Applications" },
{ "x": 448, "y": 344, "type": "file", "path": “connect.app” }
]
}
Any idea or other easy cli tool ? I need to plug the tool inside a build server which generate automatically the app.
Thanks
Curly quotes are your syntax error. "connect.app" vs. “connect.app”

Parsing 'Complex' JSON with Pig

Say I have some moderately complex JSON like
{
"revenue": 100,
"products":[
{"name": "Apple", "price": 50},
{"name": "Banana", "price": 50}
]
}
Obviously this this a bit contrived, but what's the best way to map this to pig using JsonLoader.
I've tried
a = LOAD 'test.json' USING
JsonLoader('revenue:int,products:[(name:chararray,price:int)]');
or
a = LOAD 'test.json' USING
JsonLoader('revenue:int,products:[{(name:chararray,price:int)]}');
However, when I DUMP A, I get (100,) for both.
I've also tried
a = LOAD '/json/complex.json'
USING JsonLoader('revenue:int,products:[{name:chararray,price:int}]');
which errors out with ERROR 1200: <line 1, column 28> mismatched input 'chararray' expecting LEFT_PAREN.
What's the best way to parse this for future use?
Thanks
For posterity,
a = LOAD 'test.json' USING
JsonLoader('revenue:int,products:{(name:chararray,price:int)}');