Skip to content

get data from outside #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Willi180 opened this issue Dec 29, 2021 · 2 comments
Open

get data from outside #1

Willi180 opened this issue Dec 29, 2021 · 2 comments

Comments

@Willi180
Copy link

Hello, I thank you for Your code. I have a Question.

`
myForm.addEventListener("submit", function (e) {
e.preventDefault();
const input = csvFile.files[0];
const reader = new FileReader();

  reader.onload = function (e) {
    const text = e.target.result;
    const data = csvToArray(text);
    document.write(JSON.stringify(data));
  };
  
  reader.readAsText(input);
});

`

how can I get data from outside for use it in anover functions as Parameter?

best regards
Wilhelm

@codewithnathan97
Copy link
Owner

Hi,

Do you mean you want to pass the array to another function as a parameter?

The csv data is saved under the variable data on line 47, so you just need to pass it into another function as you need.

In the example, I choose to write the output to the body at line 48, but you can pass it to another function there as well.

For example:

const data = csvToArray(text)
myFunction(data)
};

function myFunction(data){
  // do something with data here...
}

@Willi180
Copy link
Author

Willi180 commented Jan 1, 2022

Hi, thank You!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants