Code Monkey home page Code Monkey logo

Comments (3)

Unending avatar Unending commented on May 25, 2024

I don't think the CSV Agent works the way you want it to.

When using the serialise function it takes in multiple events and combines them into a single CSV format. It doesn't remap objects from a single JSON to a single CSV and it doesn't actually create files.

Example:
Send the following two separate events:
{ "key": "1707838936", "title": "foo", "price": "111" }
{ "key": "1707849865", "title": "bar", "price": "222" }

With default CSV Agent options + "mode": "serialize" and "data_path": "$" This will result in the payload:

{
  "data": "\"key\",\"title\",\"price\"\n\"1707838936\",\"foo\",\"111\"\n\"1707849865\",\"bar\",\"222\"\n"
}

I you then send that event to the Local File Agent it will write it to disk as:

"key","title","price"
"1707838936","foo","111"
"1707849865","bar","222"

from huginn.

radry avatar radry commented on May 25, 2024

I wanted to send it to an FTP Agent, not Local File Agent. However the FTP Agent writes a nonsense CSV File.

Does that mean the CSV Agent absolutely needs the local file Agent to translate the serialized string into an actual CSV compliant File? FTP Agent can't do it aparently.

Also, I can't send separate events to the CSV Agent because I want to read data from a Key Value Store Agent and then send it as one event containing all the data.

Essentially what I want is: Several Agents send Events to the Key Value Store Agent. At certain intervals the collected Data is written into a CSV File and published to an FTP.

As a workaround I currently just publish a JSON File, which works with the current agent setup.

from huginn.

Unending avatar Unending commented on May 25, 2024

The CSV agent just creates an event with a json name value pair, which contains just a string of characters in it. It doesn't matter whether you send it to the Local File Agent or the Ftpsite Agent (or any other agent), and just writes the data to file. There is no further "translation" happening.

Previous example (escaped JSON event):
{ "data": "\"key\",\"title\",\"price\"\n\"1707838936\",\"foo\",\"111\"\n\"1707849865\",\"bar\",\"222\"\n" }

When writing the content of "data" that would be:
"key","title","price"\n"1707838936","foo","111"\n"1707849865","bar","222"

Which is the same as

"key","title","price"
"1707838936","foo","111"
"1707849865","bar","222"

Which is a valid CSV file.

from huginn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.