Skip to content
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

Encloser does not take into account ";" when using ";" as the CSV delimiter #264

Closed
Fedduh opened this issue Dec 22, 2023 · 0 comments
Closed

Comments

@Fedduh
Copy link

Fedduh commented Dec 22, 2023

I noticed that there is an encloser function. In the comments it states that when using a comma in the field, it will be enclosed by "".

I'm using types.csv with delimiter ";". But if my cell contains ";" it will not enclose them.
I suppose the encloser function should take the chosen delimiter into account (or both "," and ";").

// Rule: Fields that contain commas must begin and end with double quotes.
// .. other rules
function encloser (value: string) {
const enclosingCharacter = /,|"|\n/.test(value) ? '"' : ''
const escaped = value.replace(/"/g, '""')

return ${enclosingCharacter}${escaped}${enclosingCharacter}
}

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

1 participant