Despite the COVID-19 outbreak, our team continues operating at full speed. We are always here to support and answer all your questions.

Feel free to reach out by filling this quick form.

Fill the form
Get Free Trial

export CSV to local JSON variable to share with multiple flexmonster instances

Answered
Michael T asked on August 14, 2020

On a page with multiple FM instances,
Interested in being able to:

  1. Load a CSV into one instance of FM
  2. Export the loaded CSV data into an equivalent JSON format and assign it to a local variable. 

    This would allow us to 

  3. Load the exported JSON data into other instances of FM

And would allow for efficient ‘one time’ loading of data from a CSV into multiple instances. Is this possible?
Thank you

3 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster August 14, 2020

Hello,
 
Thank you for writing to us.
 
Our team wants to explain that Flexmonster does not provide the possibility to export data in JSON format.
Also, we want to notice that the described approach implies saving three data set copies on the client’s page: one in each instance of Flexmonster and one assigned to the local variable. In its turn, when loading the same data set for both instances from the CSV data source, only two copies of the data set are stored on the page.
 
However, in case the goal of the described optimization is to reduce the load on the network (CSV data is passed through the network once), we suggest using the following approach. Convert your CSV data in JSON format on the server-side, pass it to the client (for example, using AJAX), and assign it to the local variable. Next, the mentioned variable can be used as a data source for both instances.
 
Finally, we want to ask you about the reason such optimization is needed in your case. Is it connected with your data set size, or with network limitations? Detailed information on this matter would allow us to recommend the most suitable option for you.
 
Our team is looking forward to hearing from you.
Do not hesitate to contact us in case further questions arise.
 
Kind regards,
Illia

Public
Michael T August 14, 2020

Thank you for the quick response.
I understand the conversion on the server side is one method, but JSON is larger than CSV. And if we cannot use Data Server, I was thinking there may be a clever way to get the benefits of using ‘inline’ JSON (i.e. 1 data, multiple FM instances)
Based on your response regarding three instances of data, I may not have been clear enough in my last message.
Assumptions:

  • Flexmonster is able to “Save” a report with the embedData option. (This results in a JSON file saved either locally or remotely)
  • Flexmonster can load JSON data from a variable (inline data)

If we could:

  1. Save the “Saved” report to a javascript variable on the browser
    (instead of local / remote file system)
  2. Extract the embedded data from that variable in JSON format
  3. Pass that variable to the other Flexmonster instances to initialize them

It allows us to have the benefit of CSV loading (smaller file) without requiring to load it multiple times across the network for different instances of FM.
 

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster August 17, 2020

Hello, Michael,
 
Thank you for providing us with additional information on this matter.
 
Our team wants to explain that the embedData parameter of the save API call allows embedding data only while saving the report locally or on the server. Flexmonster does not provide the possibility to retrieve such data and assign it to the variable.
 
Concerning the approach implying the server-side data conversion.
We want to explain that Flexmonster supports another JSON format represented as an array of arrays, where each sub-array contains ordered values. See the array of objects sample below:

[
[
"Category",
"Color",
"Price",
"Quantity"
],
["Ice-cream", "red", 23.32, 4],
["Ice-cream", "yellow", 4.2, 3],
["Sweets", "red", 45.3, 2],
["Candies", "orange", 22.65, 7]
]

In case the mentioned JSON format is used, the difference in size will be insignificant comparing to CSV.
We recommend referring to our documentation in order to get detailed information about using JSON as a data source for Flexmonster.
 
Also, we want to take an interest in what exact reasons prevent you from using the Data Server.
 
Our team is looking forward to hearing from you.
Please let us know in case any further questions arise.
 
Kind regards,
Illia

Please login or Register to Submit Answer