i need to create a json file for the variable lv_json in eclipse-adt
lv_json = {"CUSTOMER_ID":"0000010001","CUSTOMER":"IDADMIN","ADDRESS":"Chennai"}
{"CUSTOMER_ID":"0000010004","CUSTOMER":"IDADMIN","ADDRESS":"Bangalore"}
i am using the file save dialog and gui_download of cl_gui_frontend_services but shows error as "cl_gui_frontend_services are not permitted" how to solve this error.
Related
I am trying to craft a Robot Framework test that will iterate through different sites and login to them. There are two different kinds of login procedures and I've written up login steps for each. Those are stored as keywords. But I'm running in the URLs through a CSV file. The file contains the URL, and the "login_type", A or B. I want to iterate this through a FOR loop, to where I just have to call the file at runtime and the CSV file will take care of the rest.
But I am getting an error message that says "'url' must be a string." I'm not sure if my problem is the CSV file or my loop structure is wrong. Here is my code:
*** Settings ***
Documentation Store URLs in CSV and identify login type
Library Zoomba.GUILibrary
Library Process
Library CSVLibrary
Library Collections
Resource ../resource.robot
Suite Teardown Close All Browsers
*** Variables ***
${browser} chrome
${url} https://example1.edu
${CSV_FILE} C:/CSV.csv
*** Test Cases ***
Example Test
${urls} Read Csv File To List ${CSV_FILE}
FOR ${url} IN #{urls}
Open Browser ${url} ${browser}
${login_type} Get CSV Data ${url} login_type
Run Keyword If '${login_type}' == 'TYPE A' A Login <--stored keyword
Run Keyword If '${login_type}' == 'TYPE B' B Login <--stored keyword
Log To Console ${url} verified.
END
Here is the CSV file I'm using.
What am I doing wrong here? Can anybody answer this?
You should try to debug your test by logging the values. For example, after ${urls} Read Csv File To List ${CSV_FILE} you could have a Log Many ${urls}.
Then check why ${url} is not really a string. You could also try to force it to be a string by quoting, '${url}' or "${url}".
Working on Android 10/Q os with Nexus 5 API 29 on emulator and using MediaStore.
My application has created correctly a .json file (config.json) in Download/myfolder.
Further away in app I do a Query() for this file & app finds and reads it ok.
From my PC I copy another .json file (data.json) to myfolder.
Now the problems :
When I do a Query(), this last file is not found : Query() cursor.Count returns 0.
I have tried many selection but without success.
My last test is (mimeType is application/json)
string selection=$"{(string)APM.MediaColumns.MimeType}=? AND
{APMDOWNLOADS.InterfaceConsts.RelativePath} like ?";
string[] selectionArgs = new string[] { mimeType, $"Download/{AppInfo.Name}" };
Here Query Count is 0
if I suppress the RelativePath in selection I find only the config.json file
if I replace the AND by OR in selection I find only the config.json file
the AND does not work
the manually added file data.json is never found
the added RelativePath does not seem to work in the selection
I am new with MediaStore.
Can anyone find what I am doing wrong ?
Thanks in advance.
I am trying to read a csv file in a firebase function so that I can process the file and do the rest operations using the data.
import * as csv from "csvtojson";
const csvFilePath = "<gdrive shared link>"
try{
console.log("First Method...")
csv()
.fromFile(csvFilePath)
.then((jsonObj: any)=>{
console.log("jsonObj....",JSON.stringify(jsonObj));
})
console.log("Second Method...")
const jsonArray=await csv().fromFile(csvFilePath);
console.log("jsonArray...", JSON.stringify(jsonArray))
}
catch(e){
console.log("error",JSON.stringify(e))
}
The above mentioned are the 2 methods I have tried for reading the csv but both shows the firebase error
'Error: File does not exist. Check to make sure the file path to your csv is correct.'
In case of 'csvFilePath' I have tried 2 methods
Just added the csv file in same folder of the function and added the code like
const csvFilePath = "./student.csv"
Added the same file to google drive and changed the access permissions to anyone with the link can read and edit and given the path to same
const csvFilePath = "<gdrive shared link>"
Both shows the same error. In case of google drive I don't want to use any sort of google credential because I was intented to read a simple csv file in firebase function.
I will start by proposing that you convert your csv to json locally or without the function and see if it works. This is because I see you are using ES6 imports which might be causing an issue since all the documentation uses require. You can also try CSV Parse or some solutions provided in this question as an alternative, trying them without the function to check if it actually works and discard it. Actually, you can upload the JSON once you have converted it from the csv, but that depends on what you are trying to do.
I think the best way to achieve this, is following the approach given in this question, that first uploads the file into cloud storage and using onFinalize() to trigger the conversion.
Also, will address these three questions that went through similar issues with the path. They were able to fix it by adding __dirname. Each one has some extra useful information.
Context for "relative paths" seems to change to the calling module if a module is imported
The csvtojson converter ignores my file name and just puts undefined
How to avoid the error which throws a csvtojson
I am working on a scheduling/planning program in OCaml and I want to be able to use an iCal file as an input, but I can't figure out how to parse the file into my own calendar type in OCaml. Ideally, I want to be able to read an iCal file in the same way that you can read a json file using Yojson. Any ideas for how I could accomplish this?
If you're talking about the ICalendar format then there is the OCaml library icalendar that can read it. You can install it with
opam install icalendar
It is pretty undocumented so here is an example program that will read and print back a calendar.
open Format
let read filename =
let buf = Buffer.create 4096 in
let src = open_in filename in
let rec loop () = loop (Buffer.add_channel buf src 4096) in
try loop () with End_of_file -> close_in src; Buffer.contents buf
let main filename =
match Icalendar.parse (read filename) with
| Error failure ->
eprintf "Failed to read file %s %s#\n%!" filename failure
| Ok calendar ->
printf "%a#\n%!" Icalendar.pp calendar
let () = main Sys.argv.(1)
Note, that I also had to write the read function that will read the whole file into a string. This function is not a part of the standard library but is commonly provided by other libraries, e.g., Base, Core, Batteries.
To build the program, create an empty folder, put the code into a file, e.g., example.ml and then issue the following command in that folder:
ocamlbuild -pkg icalendar example.native
You can then use the built binary as
./example.native input.ics
where input.ics is the sample input.
I am getting a 404 error when trying to access a file metadata with Google Drive Api, files.get method.
I've tried to reproduce the error using the same user and the same fileID, from the Api test page: https://developers.google.com/drive/api/v3/reference/files/get
But I can't reproduce the error. From this page I get a 200 response and I get the metadata I need (file name, etc.) That means the FileID is correct and the file does exist
According to Google the 404 error can be due to insufficient permissions (I don't think this is the case, in my code I am using https://www.googleapis.com/auth/drive which I understand includes access to metadata). Or else the file does not exist, which is also not the case.
I don't know what else to try. Here's my simple Python code:
#GET THE FILES LIST - THIS WORKS PERFECTLY:
theFiles = drive_service.files().list(pageSize=1000,q="trashed=false and mimeType != 'application/vnd.google-apps.folder'",orderBy="quotaBytesUsed desc, name, modifiedTime desc",fields="files(id,name,modifiedTime,quotaBytesUsed,starred,webViewLink, parents)").execute()
dicFiles = theFiles.get('files',[])
#GET METADATA
for item in dicFiles:
parentID=item.get('parents',[0])
#HERE I GET THE 404 ERROR
metadata= drive_service.files().get(fileId=parentID).execute()
Error:
https://www.googleapis.com/drive/v3/files/%5B%271uP0WhJXtjHBSnBb4KS80GexG9P5OLH-p%27%5D?alt=json returned "File not found: ['1uP0WhJXtjHBSnBb4KS80GexG9P5OLH-p'].">
Ok, I found the problem.
item.get('parents',[0]) wasn't returning a string, but a list.
I replaced that by item['parents'][0] and now it's working.