I’m working with the basic twitter bot template, but I feel totally out of my depth here.
Here’s the basic idea of what I’m trying to do: I have a text file that contains a lot of snippets of text (no, A LOT. Like, it’s a 6MB plaintext file, and it has about 50,000 unique snippets inside).
I turned the text file into a JSON file, and tried to make each snippet into a JSON object with an index property (integer) and a content property (the content as a string).
I want a Twitter bot that tweets each snippet in sequence.
I uploaded my JSON file to the assets folder, but now I don’t know how to get the text out of there. The JSON file looks like this:
data = '[
{"content":"foo","id":1},
{"content":"bar","id":2},
…
{"content":"baz","id":49999},
]';
What do I do next? I tried the “Ask for help” feature but it disappeared after a few seconds.
There will be an issue with your JSON, the single quote before and after the opening and closing should be removed. You may also want to remove the data = as well. Then in your main file you can load your JSON using something like
The path ./assests/data.json is likely incorrect, I just used that as an example, which would only work if you had the file in one of the directories You actually wouldn’t be able to require from the assets URL, sorry about that. I recommend going into the console and using wget to download the file to the local file system. The command would be something like