Skip to content

Fix authors field parsing in CSV import #4

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
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

adryserage
Copy link
Contributor

Issue #2 Corrected the parsing of the 'authors' field in the fromANDREWROBERTSList function to handle empty values, preventing errors when authors are missing in the CSV data.

Corrected the parsing of the 'authors' field in the fromANDREWROBERTSList function to handle empty values, preventing errors when authors are missing in the CSV data.
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @adryserage, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the CSV import functionality, specifically related to the parsing of the 'authors' field. The change ensures that the application can now gracefully handle instances where the 'authors' field in the imported CSV data is empty, thereby preventing parsing failures and enhancing the overall robustness of the data import process.

Highlights

  • CSV Parsing Robustness: Modified the fromANDREWROBERTSList function in searchApp.html to prevent errors when parsing the 'authors' field from CSV data if the field is empty or missing. Previously, an empty 'authors' field would cause a parsing error.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes a crash that occurs when parsing the authors field from a CSV file if the field is empty. The change is robust and consistent with how other fields like tags are handled.

During the review, I noticed a few other potential issues within the same function that could be improved:

  • A bug in the date parsing logic that could lead to incorrect dates.
  • Some opportunities to improve code readability and maintainability regarding function naming and data destructuring.

I've added specific comments with suggestions for these points.

searchApp.html Outdated
})
.catch(err => console.log(err));

function fromANDREWROBERTSList(csv, object) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

JavaScript function names are conventionally written in camelCase. To adhere to common style guides and improve code consistency, fromANDREWROBERTSList should be renamed to fromAndrewRobertsList. Remember to update the call site on line 248 as well.

Suggested change
function fromANDREWROBERTSList(csv, object) {
function fromAndrewRobertsList(csv, object) {

searchApp.html Outdated
}
const ar = parsedCsv.data;
ar.shift();
const objAr = ar.reduce((o, [name,description,projectKey,moreinf,,gitHub,created,,,,authors,tags]) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This array destructuring with multiple empty slots for unused CSV columns is hard to read and can be brittle if the CSV structure changes. For improved readability and maintainability, consider accessing the row elements by their index and assigning them to clearly named variables inside the reduce callback.

For example:

const objAr = ar.reduce((o, row) => {
  const name = row[0];
  const description = row[1];
  // ... and so on for other columns
  const authors = row[11];
  const tags = row[12];

  // ... rest of the logic
  
  return o;
}, []);

adryserage and others added 3 commits July 14, 2025 02:19
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Added update notes for v1.1.2 in README.md and Update.md, detailing fixes for TypeError in `fromANDREWROBERTSList`, null checks for authors field, and improved error handling for Andrew Roberts' spreadsheet data.
@adryserage
Copy link
Contributor Author

adryserage commented Jul 14, 2025

@gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes a TypeError that occurred when parsing CSV data with an empty 'authors' field. It also includes a crucial fix for incorrect date parsing where the month was off by one. The changes effectively improve the application's robustness. I've provided a couple of suggestions to further enhance the data parsing logic for both dates and author names, which will make the code cleaner and more resilient to variations in data formatting.

adryserage and others added 2 commits July 14, 2025 02:26
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

1 participant