0

Using a list of search keywords stored in CSV file, using let keyword of searchkeywords, how do I modify to have forEach?

Viewed every listed similar question, none provided a solution.

Set a constant

const searchkeywords = readKeyWords('./datain.csv','utf-8');

Using inside async function main

for (let keyword of searchkeywords)

Hope to use

listofkeywords.forEach(sync (keyword) => {

Cannot discover how to modify.

Tahor Sui Juris
  • 131
  • 1
  • 12
  • Is there a reason to use `.forEach` over `for...of`? You also don't show what you are trying to call in those loops that is `async`. – crashmstr Jun 06 '19 at 15:50
  • @crashmstr , How would I set the const to the file? I tried: ` async function printFiles () { const files = await getFilePaths('./datain/testdata.csv','utf-8'); for (let file of files) { const contents = await fs.readFile(file, 'utf8'); console.log(contents); } } ` it does not return any data in console.log – Tahor Sui Juris Jun 06 '19 at 17:59
  • Could not format code properly, above. – Tahor Sui Juris Jun 06 '19 at 18:06
  • @TahorSuiJuris You might want to [edit] your question to include the relevant code. Btw, you might want to `console.log(files)` to check whether it is an empty array, and then fix `getFilePaths`? – Bergi Jun 06 '19 at 18:47
  • @Bergi above is the relevant code, tried ` tried 4 spaces, the code is not posting as code. – Tahor Sui Juris Jun 06 '19 at 20:17
  • @TahorSuiJuris In comments, only `\`inline code\`` works. For posting larger chunks of code, use the body of your question. – Bergi Jun 06 '19 at 20:21
  • @Bergi posted as a new question: [link](https://stackoverflow.com/questions/56484600/how-would-i-set-define-the-const-files) – Tahor Sui Juris Jun 06 '19 at 20:24
  • You should just have [edit]ed this question, but well... let's continue over there. – Bergi Jun 06 '19 at 20:26

0 Answers0