Skip to content

feat: add support for column-based reading of CSV files - #982

Open
sapienza88 wants to merge 9 commits into
apache:mainfrom
sapienza88:column_support_csv
Open

feat: add support for column-based reading of CSV files#982
sapienza88 wants to merge 9 commits into
apache:mainfrom
sapienza88:column_support_csv

Conversation

@sapienza88

@sapienza88 sapienza88 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Purpose of the pull request

Related: #950
Related: #942 (XLSX Format Implementation)

What's changed?

  • Added support for column-based reading (CSV only).

Column filtering behavior: CsvExcelReadExecutor#dealRecord

When includeColumnIndexes != null:

  • Only process target columns
  • Rewrite target columns’ internal indexes to consecutive (0-based)

When includeColumnIndexes == null:

  • Keep the original behavior

API Usage Example

// data for csv
NO,Name,Age,Password
1,Jackson,22,123456

List<Map<Integer, String>> results = FesodSheet.read(pathname)
		.csv()
		.includeColumnIndexes(Arrays.asList(1, 3))
		.doReadSync();

Map<Integer, String> data = results.get(0);

assertEquals(2, data.size());
assertEquals("Jackson", data.get(0));
assertEquals("123456", data.get(1));

Checklist

  • I have read the Contributor Guide.
  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

@sapienza88
sapienza88 force-pushed the column_support_csv branch from bca58fe to ab2343a Compare July 30, 2026 22:10
@sapienza88 sapienza88 changed the title CSV Column Filtering support + Test Feat: CSV Column Filtering Support + Test Aug 2, 2026
@sapienza88

Copy link
Copy Markdown
Contributor Author

@delei @bengbengbalabalabeng pls run CI on this

@bengbengbalabalabeng

Copy link
Copy Markdown
Contributor

Please resolve the code conflict issue first.

Comment thread fesod-sheet/src/test/java/org/apache/fesod/sheet/FesodSheetTest.java Outdated
Comment thread fesod-sheet/src/test/java/org/apache/fesod/sheet/FesodSheetTest.java Outdated
Comment on lines +267 to +271
List<Map<Integer, String>> readResults = FesodSheet.read(csvFile)
.csv()
.includeColumnIndexes(targetColumns)
.sheet(0)
.doReadSync();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Method call chain error.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Can you point out the test example?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The includeColumnIndexes() method is not defined in .csv() (CsvReaderBuilder).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The includeColumnIndexes() method is not defined in .read(...) (ExcelReaderBuilder).

Please confirm that the unit tests pass locally before submitting.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@bengbengbalabalabeng the test now passes locally, pls check again and merge this if all is ok.

@sapienza88

sapienza88 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@bengbengbalabalabeng @delei is csv supporting non header data?
does it make possible writing something like the following to make reading data without header possible (eg. read data from row 0 : no header)?:

FesodSheet.read(fileName, DemoData.class, new DemoDataListener())
            .sheet()
            .headRowNumber(-1) // or 0
            .doRead();

as of now the default is 1 so the first row will always be skipped (because it is considered header) when reading data

@bengbengbalabalabeng

Copy link
Copy Markdown
Contributor

@bengbengbalabalabeng @delei is csv supporting non header data? does it make possible writing something like the following to make reading data without header possible (eg. read data from row 0 : no header)?:

FesodSheet.read(fileName, DemoData.class, new DemoDataListener())
            .sheet()
            .headRowNumber(-1) // or 0
            .doRead();

as of now the default is 1 so the first row will always be skipped (because it is considered header) when reading data

.headRowNumber(0) with non-head read: yes

@bengbengbalabalabeng

Copy link
Copy Markdown
Contributor

Hi @sapienza88,

Please help confirm whether the updated PR description accurately reflects the changes.

@sapienza88

Copy link
Copy Markdown
Contributor Author

Hi @sapienza88,

Please help confirm whether the updated PR description accurately reflects the changes.

Yes it does. Thanks

@bengbengbalabalabeng bengbengbalabalabeng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.

merge in 24h.

@delei delei changed the title Feat: CSV Column Filtering Support + Test feat: add support for column-based reading of CSV files Aug 5, 2026
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.

2 participants