Skip to content
Fix Code Error

Tag: json

Python removing .jsonl extension when converting JsonL to CSV File

July 18, 2021 by Code Error

Posted By: Anonymous I have with me a script that converts jsonl files in a selected directory to csv files in another specified location. However, upon converting the files to csv format, the final created csv file contains a .jsonl extension before the .csv (Think file.jsonl.csv) Any ideas on how to remove the .jsonl extension …

Continue Reading

How to import data from custom template tag to javascript? Django

July 18, 2021 by Code Error

Posted By: Anonymous How to escape js on a custom template tag? In my custom_tags.py I have registered a simple tag which simply takes data from firebase in form of array of dictionary. I want to pass this array directly to my JavaScript but doing so gives me error. my custom_tags.py – @register.simple_tag def getMessageData(): …

Continue Reading

How to get Audio track from JSON file in server?

July 18, 2021 by Code Error

Posted By: Anonymous Hello 🙂 in my Project I want to get Audio track from a JSON file file which locate it in a Server. my Audio. mp4 doesn’t want to play, I don’t know why ,, I made the same script for video and it works good just I thought if I have only …

Continue Reading

ReactJS create array from json object for select option

July 17, 2021 by Code Error

Posted By: Anonymous Hi I am very new to reactjs. I have a hosted json file as below. Json object looks like below with Around 500+ values: [ { "timestamp": "2020-03-23T14:00:00.000Z", "symbol": "CMG", "name": "Chipotle Mexican Grill", "industry": "Consumer Discretionary", "open": 561.31, "high": 602.265, "low": 551.21, "close": 588.71, "volumes": 1281710 }, { "timestamp": "2020-03-23T14:00:00.000Z", "symbol": …

Continue Reading

Uncaught Error: Undefined constant “image”

July 17, 2021 by Code Error

Posted By: Anonymous I’ve an error when i execute the API JSON : This is my code : $image = get_the_post_thumbnail_url($post); if (!image) { $image = ""; } And the error : Uncaught Error: Undefined constant "image" in C:xampphtdocsappwp-contentthemestwentytwentyfunctions.php:873 thx Solution There is an issue in this line. if (!image) { .. it should be. …

Continue Reading

How to convert to CSV to Keyed JSON?

July 17, 2021 by Code Error

Posted By: Anonymous Currently, I’m creating to JSON with this code: import pandas as pd import csv data = pd.read_csv(r’C:UsersuserDownloadsconfig_all_env.csv’) # print(data.to_string()) df = pd.DataFrame(data) # print(df) json_file = df.to_json(orient=’index’,indent=4) print(json_file) my ‘config_all_env.csv’ looks like this _key,index,source 123456789100:LogGroup1,index1,Account1-123456789100:LogGroup1 123456789100:LogGroup2,index1,Account1-123456789100:LogGroup2 678901234200:LogGroup3,index2,Account2-678901234200:LogGroup3 678901234200:LogGroup4,index2,Account2-678901234200:LogGroup4 And the Output is like this: { "0":{ "_key":"123456789100:LogGroup1", "index":"index1", "source":"Account1-123456789100:LogGroup1" }, "1":{ "_key":"123456789100:LogGroup2", …

Continue Reading

howto insert this json(post) into mariadb?

July 17, 2021 by Code Error

Posted By: Anonymous {"11":{"counts":"0","endtimes":"18:26:36","ids":"NONE","starttimes":"18:26:05","dates":"2021-05-27 18:26:36","machineids":"10002","nums":11,"entiretimes":"00:00:31"},"12":{"counts":"14","endtimes":"18:29:09","ids":"NONE","starttimes":"18:27:4 3","dates":"2021-05-27 18:29:09","machineids":"10002","nums":12,"entiretimes":"00:01:26"},"13":{"counts":"16","endtimes":"18:32:06","ids":"NONE","starttimes":"18:30:28","dates":"2021-05-27 18:32:06","machineids":"10002","nums":13,"entiretimes":"00:00:22"} i got this data post. but i don’t know this data to maria db. nodejs(express) …… this situation …… insert into countdata ?????? ….value(body?????) Solution Assuming that the name of the table you are wanting to insert data into is called countdata, that it contains a JSON …

Continue Reading

Flatten the data frame column of list containing nested dictionaries in a unique way shown

July 17, 2021 by Code Error

Posted By: Anonymous Flattening dataframe column of the list of nested dictionaries in a way shown below. Guys, I’m new to python, but I’m trying really hard to achieve the goal but unfortunately unable to do so. current Dataframe: col1 col2 path1 [{sheetname1:{value11:length11,value12:length12,value13:length13…}}, {sheetname2:{value21:length21,value22:lenth22,…}}] resulting datafarme: col1 col2 col3 col4 path1 sheetname1 value11 length11 path1 …

Continue Reading

Link doesn’t work after deploying site on firebase

July 17, 2021 by Code Error

Posted By: Anonymous I have a problem with my website after deploying it through firebase. I have a link in my navigation that takes me to my home page. This link takes me however to the 404 page. All other links work properly. This is the website: https://okinawa-flatbellytonic.firebaseapp.com My home page with popup window my …

Continue Reading

Should you bundle a JSON or CSV file with a webapp to store default data?

July 17, 2021 by Code Error

Posted By: Anonymous I’m making a React webapp where the user can chose from a list of default data in order to create a user modifiable copy of the data. Currently, the data is in an excel file. I was planning on converting it to either CSV or JSON and simply put it in my …

Continue Reading

trying to compile my sass with css in json “npm run sass”

July 17, 2021 by Code Error

Posted By: Anonymous i have install sass i am trying to compile my sass with css in json. In the script part I think I correctly linked the sass and css files. But when I run "npm run sass" I have this problem. Why do you think? enter image description here Solution First i would …

Continue Reading

trying to convert python firebase info to json

July 17, 2021 by Code Error

Posted By: Anonymous I have a Python code where I can fech the data from firebase cloud firestore just with this code: import firebase_admin from firebase_admin import credentials from firebase_admin import firestore cred = credentials.Certificate("firebaseCredentials.json") firebase_admin.initialize_app(cred) db = firestore.client() #read data #Getting a Document with a known ID results = db.collection(‘users’).document(‘HtregtuuDDVWglz9DjobFGH9jMo1’).collection(‘chats’).get() for result in results: …

Continue Reading

JSON Response Formatted Odd

July 16, 2021 by Code Error

Posted By: Anonymous I would appreciate help if possible with this. I’ve come to expect JSON payloads in a particular format and I do not yet know why it’s not returning as such. The payload is including fields for $id and $values for example this is the response I’m getting (this is .Net 5) { …

Continue Reading

My node.js json parse function throws error

July 16, 2021 by Code Error

Posted By: Anonymous [ JAVASCRIPT NEWBIE ] Hi, I am trying to parse json data to extract different values but I am getting errors. Could you please help? JSON Data Raw JSON data sample: {"records":{"expiryDates":["03-Jun-2021","10-Jun-2021","17-Jun-2021","24-Jun-2021","01-Jul-2021","08-Jul-2021","15-Jul-2021","22-Jul-2021","29-Jul-2021","26-Aug-2021","30-Sep-2021","30-Dec-2021"],"data":[{"strikePrice":18000,"expiryDate":"30-Sep-2021","PE":{"strikePrice":18000,"expiryDate":"30-Sep-2021","underlying":"BANKNIFTY","identifier":"OPTIDXBANKNIFTY30-09-2021PE18000.00","openInterest":1,"changeinOpenInterest":0,"pchangeinOpenInterest":0,"totalTradedVolume":0,"impliedVolatility":0,"lastPrice":0.25,"change":0,"pChange":0,"totalBuyQuantity":23100,"totalSellQuantity":0,"bidQty":10000,"bidprice":5,"askQty":0,"askPrice":0,"underlyingValue":35141.45}},{"strikePrice":23000,"expiryDate":"24-Jun-2021","PE":{"strikePrice":23000,"expiryDate":"24-Jun-2021","underlying":"BANKNIFTY","identifier":"OPTIDXBANKNIFTY24-06-2021PE23000.00","openInterest":534,"changeinOpenInterest":-6,"pchangeinOpenInterest":-1.1111111111111112,"totalTradedVolume":82,"impliedVolatility":63.23,"lastPrice":9.5,"change":-2.5,"pChange":-20.833333333333336,"totalBuyQuantity":2775,"totalSellQuantity":875,"bidQty":50,"bidprice":9.5,"askQty":50,"askPrice":9.95,"underlyingValue":35141.45}},{"strikePrice":24000,"expiryDate":"30-Sep-2021","PE":{"strikePrice":24000,"expiryDate":"30-Sep-2021","underlying":"BANKNIFTY","identifier":"OPTIDXBANKNIFTY30-09-2021PE24000.00","openInterest":0,"changeinOpenInterest":0,"pchangeinOpenInterest":0,"totalTradedVolume":0,"impliedVolatility":0,"lastPrice":0,"change":0,"pChange":0,"totalBuyQuantity":20575,"totalSellQuantity":0,"bidQty":5000,"bidprice":5,"askQty":0,"askPrice":0,"underlyingValue":35141.45}},{"strikePrice":24000,"expiryDate":"30-Dec-2021","PE":{"strikePrice":24000,"expiryDate":"30-Dec-2021","underlying":"BANKNIFTY","identifier":"OPTIDXBANKNIFTY30-12-2021PE24000.00","openInterest":11,"changeinOpenInterest":0,"pchangeinOpenInterest":0,"totalTradedVolume":0,"impliedVolatility":0,"lastPrice":180,"change":0,"pChange":0,"totalBuyQuantity":100,"totalSellQuantity":0,"bidQty":50,"bidprice":151.55,"askQty":0,"askPrice":0,"underlyingValue":35141.45}},{"strikePrice":24000,"expiryDate":"24-Jun-2021","CE":{"strikePrice":24000,"expiryDate":"24-Jun-2021","underlying":"BANKNIFTY","identifier":"OPTIDXBANKNIFTY24-06-2021CE24000.00","openInterest":1,"changeinOpenInterest":0,"pchangeinOpenInterest":0,"totalTradedVolume":0,"impliedVolatility":0,"lastPrice":9223.8,"change":0,"pChange":0,"totalBuyQuantity":3650,"totalSellQuantity":2900,"bidQty":750,"bidprice":11073.95,"askQty":500,"askPrice":11544.4,"underlyingValue":35141.45},"PE": My node.js code: async function formatDataAndStore(resp){ return new Promise((resolve,reject)=>{ //let myDate = new Date(); //let currentTime = myDate.getHours()*100 + Math.floor(myDate.getMinutes()/5)*5; …

Continue Reading

If object of a nested array in mongodb doesn’t have a field, then display default value

July 16, 2021 by Code Error

Posted By: Anonymous 1.) What I have done I am trying to query over data in MongoDB which looks like this: "AllData": [ { "name": "Company 1", "data": [ { "Brand": "Brand 1", // Brand field present "Product Name": "Product 1", }, { "Brand": "Brand 1", // Brand field present "Product Name": "Product 2", }, …

Continue Reading

Jackson cannot parse body of a POST request

July 15, 2021 by Code Error

Posted By: Anonymous I am using Spring Boot to implement two web services, User and Book, and I am implementing the POST methods. When I send a POST request, i include the hard-coded JSON object in the HTTP Body: I am working at the same time on the two services, and while the creation of …

Continue Reading

ErrorException: Undefined index: id

July 15, 2021 by Code Error

Posted By: Anonymous I’m trying to fetch data from this JSON URL https://api.github.com/users/Kirolos-victor/events/public but I don’t understand why am I getting this error I hope someone can help me, Thanks. public function score(Request $request) { $validator=Validator()->make($request->all(),[ ‘name’=>’required’, ]); if($validator->fails()) { return response()->json([‘message’=>’failed’,’data’=>$validator->errors()],400); } $json=Http::get("https://api.github.com/users/$request->name/events/public")->json(); $id=collect($json["id"]); return $id; } Solution looks like that end point is …

Continue Reading

Flutter send json body in Http GET Method

July 15, 2021 by Code Error

Posted By: Anonymous i tried many solutions but it still give me the same error : "Unhandled Exception: type ‘_InternalLinkedHashMap<dynamic, dynamic>’ is not a subtype of type ‘Map<String, dynamic>?’" Future<GetCustomerList> _getStateList() async { final SharedPreferences prefs = await SharedPreferences.getInstance(); var token = prefs.getString("userToken"); final String url = "http://194.195.245.189:8069/get_partners?params: {}"; Map<dynamic, dynamic> qParams = { "params": …

Continue Reading

One to many relationship in two JSON arrays, lookup results in PHP

July 15, 2021 by Code Error

Posted By: Anonymous I have two separate JSON arrays. Array 1 is called matches, Array 2 is called participants. Participants can be in many matches. I need some direction in how to look up the player id from matches within the matches array and return the corresponding participants name from the participants array. Matches contains: …

Continue Reading

Write request content into CSV file python code

July 15, 2021 by Code Error

Posted By: Anonymous I am fetching data from dashboard as json file using the following code: ursl=’https://✘✘✘✘✘✘✘✘✘’ parameter = { "access_token": ‘ABCD’, "startDate":"2021-05-23", "endDate":"2021-05-25", "userId":’ERTI’ } r = requests.get(url = ursl, params = parameter) then I save the content as json file then write it to a CSV file: data=r.content datajson=r.json() # opening the csv …

Continue Reading

How to correctly iterate over a JSON stored in state using ReactJS?

July 14, 2021 by Code Error

Posted By: Anonymous I want to iterate over my jsondata to remove elements but I get the following error this.state.jsondata is not iterable. I understand a bit the problem and for what I understand I must iterate over the items inside this.state.jsondatabut I can’t figure out how to fix it. The error appears where I …

Continue Reading

How to display all registers while, filtering by id where id it should equal to another id inside an array (VUE 3)

July 14, 2021 by Code Error

Posted By: Anonymous so I have a headless for the static content and I am managing users with firebase and saving the favs articles in a Json file. My Json looks like this: [ { "id": “0000001”, "name": “Helga”, "favorites": [ “1234”, “6789” ] }, { "id": “0000002”, "name": “Otto”, "favorites": [ “3334” ] } …

Continue Reading

Filtering a json dictionary by values Python

July 14, 2021 by Code Error

Posted By: Anonymous I am trying to write a piece of code where it filters out the values RSI, MOM, MOM_RSI within the Json file and filters by Status. I want to keep the values that has a Status of ACTIVE and get rid of the one that have a status of PAUSED. I have …

Continue Reading

Add element to an array embedded inside a sub-document in MongoDB

July 14, 2021 by Code Error

Posted By: Anonymous I have the following scheme on my MongoDB { "weekday": 0, "hour":[ { "hour": 14, "user": "user", "promoted": ["user1","user2","user3","user4"] }, { "hour": 15, "user": "user", "promoted": ["user1","user2","user3","user4"] }, ] } I want to add single elements to the "promoted" array of a certain hour, for example, add "user5" to the "promoted" array …

Continue Reading

How to get specific api response path that is in an array with google script

July 14, 2021 by Code Error

Posted By: Anonymous I have an api response that looks like this: { "dates": [ { "date": "display_date": "title": "menu_title": "items": [ { "title": }] }] } I want to get the title field. I’m not sure how to do this with Google Script? Tried the below but seems like it doesn’t work (getting null). …

Continue Reading

How to perform couple of mysqli queries and add one result into existing result array?

July 14, 2021 by Code Error

Posted By: Anonymous Need to perform couple of mysqli queries and add one result into existing result array, currently I have implemented first query, $dataQuery = "SELECT * FROM movies_table"; $sth = mysqli_query($conn, $dataQuery); $rows = array(); while($r = mysqli_fetch_assoc($sth)) { $rows[] = $r; } $respObj->status = ‘success’; $respObj->movies = $rows; $respJSON = json_encode($respObj); print …

Continue Reading

How to convert PHP Multidimensional Array to Json so it works as Json POST request?

July 14, 2021 by Code Error

Posted By: Anonymous I have the following JSON that works on Postman when performing a POST request: ‘{ "bar1": "sample", "bar2": [ { "bar1": "sample", "bar2": "sample", "bar3": "111111111", "bar4": "sample", "bar5": { "bar6": "varr", "bar7": [ -70.11111111111111, -33.11111111111111 ] } } ], "bar8": 11111 }’ However on my backend I have an Array that …

Continue Reading

@Jsonproperty neated field mapping problem

July 14, 2021 by Code Error

Posted By: Anonymous Let’s say I’m making a call to an API that responds with the following JSON for a product: { "success" : true, "message" : "ok", "product" : { "name : "food", "price" : 123 } } I’ve tried converting it with simple RequestDTO. public class RequestDTO { @JsonProperty("success") boolean success; @JsonProperty("message") boolean …

Continue Reading

Pandas dataframe from URL json data – KeyError cannot index or filter by keys

July 14, 2021 by Code Error

Posted By: Anonymous import pandas as pd url = "https://api.reserve.albertaparks.ca/api/public/campgrounds/62/availability?campingType=campsite" "&arrivalDt=01-Aug-2021&departureDt=13-Aug-2021&unitSize=40&siteType=VEH" result = pd.read_json(url) print(result) df = pd.DataFrame(result) df = df[df[‘available’]] df.set_index(‘date’, inplace=True) print(df) I’m trying to return only results where ‘available’ = True and format the results like below without the table. Probably using tabulate but not sure. date available fcfs 01-Aug-2021 True False …

Continue Reading

Python JSON TypeError : list indices must be integers or slices, not str

July 14, 2021 by Code Error

Posted By: Anonymous I am trying to loop through a dataframe but I am getting a for row in i["Attachments"]: TypeError: list indices must be integers or slices, not str My JSON file has Attachments yet it is giving me errors. I have possibly tried all ways from Stackoverflow to get this issue solved, but …

Continue Reading

Posts navigation

  • 1
  • 2
  • 3
  • 4
  • …
  • 50
  • Next

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error