-
Notifications
You must be signed in to change notification settings - Fork 3
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
1700: Refactor and clean up csv import #1765
base: main
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,6 @@ | |||
<component name="InspectionProjectProfileManager"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appeared after setting the eslint configuration in IntelliJ to automatic, I guess we want this project wide then?
@@ -0,0 +1,7 @@ | |||
import { ProjectConfig } from '../getProjectConfig' | |||
|
|||
export const getCsvHeaders = (projectConfig: ProjectConfig): string[] => [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think this is good naming? Or should we change this to columnNames
or similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm for now i think its okay because it serves this particular purpose and can't be reused that easily. But if we combine name, expiry date and extensions into one array to make it more flexible and to enable better reordering of form fields we might not need to explicitly define here the columns names in the array but just loop through and then we could rename it to getColumnNames
2dfb102
to
1a189de
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Nice refactoring 👍
Tested csv import for nuernberg and bavaria
@@ -57,7 +64,7 @@ const ImportCardsInput = ({ setCards, lineToCard, headers, isFreinetFormat }: Im | |||
const lines = content | |||
.split('\n') | |||
.filter(line => line.trim().length) | |||
.map(line => line.split(/,|;/).map(cell => cell.trim())) | |||
.map(line => line.split(/[,;]/).map(cell => cell.trim())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you explain this change
Short description
Refactor and clean up csv import to avoid implicit side effects.
Proposed changes
Side effects
Testing
Make sure that both normal and freinet CSV import still works.
Resolved issues
Fixes: #1700