Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
Opencsv
https://opencsv.sourceforge.net/
Admin
Opencsv is an easy-to-use CSV (comma-separated values) parser library for Java.
Tokens:
560,766
Snippets:
5,126
Trust Score:
10
Update:
1 week ago
Context
Chat
Benchmark
81.44
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### setup Source: https://opencsv.sourceforge.net/testapidocs/com/opencsv/CSVParserWriterSpec.html Performs setup operations and returns an Object. ```APIDOC ## setup ### Description Performs setup operations and returns an Object. ### Method SETUP ### Endpoint N/A (Java method) ### Parameters None ### Response - **Object** - The result of the setup operation. ``` -------------------------------- ### Sample CSV data with custom header names Source: https://opencsv.sourceforge.net/?__cf_chl_rt_tk=42GD6vvWNPMUKxynIG7Q42SztXwJGhMEufNI01v4NcU-1781860008-1.0.1.1-w_mC3jUXzT3mc5vgOkM5H5lBpvNKCUoJRc.F1815M6Q Example CSV with headers containing spaces and a numeric start, used to demonstrate custom column names and required fields. ```csv First name,Last name,1 visit only John,Doe,true Jane,Doe,false ``` -------------------------------- ### Using @PreAssignmentProcessor with ConvertWordNullToNull Source: https://opencsv.sourceforge.net/apidocs/com/opencsv/bean/processor/ConvertWordNullToNull.html Annotation usage example from Integration tests FR138MockBean. Without this annotation, a CSVMalformedException is thrown when converting the string "null" to an int; with it, the int gets a default value of 0. ```java @PreAssignmentProcessor(processor = ConvertWordNullToNull.class) private int num; ``` -------------------------------- ### build() Source: https://opencsv.sourceforge.net/apidocs/com/opencsv/CSVReaderHeaderAwareBuilder.html Creates the CSVReaderHeaderAware. ```APIDOC ## build() ### Description Creates the CSVReaderHeaderAware. ### Returns `CSVReaderHeaderAware` - The built CSVReaderHeaderAware instance. ``` -------------------------------- ### build Source: https://opencsv.sourceforge.net/apidocs/com/opencsv/CSVReaderHeaderAwareBuilder.html Creates the CSVReaderHeaderAware. ```APIDOC ## build ### Description Creates the `CSVReaderHeaderAware`. ### Method build ### Signature `public CSVReaderHeaderAware build() throws RuntimeException` ### Returns The `CSVReaderHeaderAware` based on the set criteria. ### Throws - `RuntimeException` - If the header mapping cannot be initialized from the first line of data. ``` -------------------------------- ### CsvToBeanAsIteratorTest.java - iterator-based CSV to bean tests Source: https://opencsv.sourceforge.net/xref-test/com/opencsv/bean/CsvToBeanAsIteratorTest.html The complete test class CsvToBeanAsIteratorTest from the opencsv source, covering iterator-based CSV-to-bean conversion. It includes a test CSV string, a CsvToBeanFilter example, and tests for exception handling, parsing without annotations, and unsupported remove operations. The code is truncated at the start of the last test method. ```java 1 _/*_ 2 _ * Copyright 2017 Andrew Rucker Jones._ 3 _ *_ 4 _ * Licensed under the Apache License, Version 2.0 (the "License");_ 5 _ * you may not use this file except in compliance with the License._ 6 _ * You may obtain a copy of the License at_ 7 _ *_ 8 _ * http://www.apache.org/licenses/LICENSE-2.0_ 9 _ *_ 10 _ * Unless required by applicable law or agreed to in writing, software_ 11 _ * distributed under the License is distributed on an "AS IS" BASIS, 12 _ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 _ * See the License for the specific language governing permissions and_ 14 _ * limitations under the License._ 15 _ */_ 16 **package** com.opencsv.bean; 17 18 **import** com.opencsv.CSVParser; 19 **import** com.opencsv.CSVParserBuilder; 20 **import** com.opencsv.CSVReader; 21 **import** com.opencsv.CSVReaderBuilder; 22 **import** com.opencsv.bean.mocks.*; 23 **import** com.opencsv.enums.CSVReaderNullFieldIndicator; 24 **import** com.opencsv.exceptions.CsvException; 25 **import** com.opencsv.exceptions.CsvRequiredFieldEmptyException; 26 **import** org.junit.jupiter.api.Assertions; 27 **import** org.junit.jupiter.api.Test; 28 29 **import** java.io.*; 30 **import** java.util.Iterator; 31 **import** java.util.List; 32 **import** java.util.NoSuchElementException; 33 34 **import** **static** org.junit.jupiter.api.Assertions.*; 35 36 **public** **class** CsvToBeanAsIteratorTest { 37 38 **private** **static** **final** String TEST_STRING = "name,orderNumber,num\n" 39 + "kyle,abc123456,123\n" 40 + "jimmy,def098765,456 "; 41 42 **private** CSVReader createReader() { 43 StringReader reader = **new** StringReader(TEST_STRING); 44 **return** **new** CSVReader(reader); 45 } 46 47 _// This class is an example where you would want to use the BeanVerifier instead as the position of_ 48 _// the number could be different if you are getting data from different sources._ 49 **private** **static** **class** FilterSmallNumbers **implements** CsvToBeanFilter { 50 @Override 51 **public** **boolean** allowLine(String[] line) { 52 **return** Integer.parseInt(line[2].trim()) > 200; 53 } 54 } 55 56 @Test 57 **public** **void** throwRuntimeExceptionWhenExceptionIsThrown() { 58 CsvToBean<Object> bean = **new** CsvToBean<>(); 59 bean.setMappingStrategy(**new** ErrorHeaderMappingStrategy<>()); 60 bean.setCsvReader(createReader()); 61 Assertions.assertThrows(RuntimeException.**class**, () -> { 62 **for** (Object o : bean) { 63 } 64 }); 65 } 66 67 @Test 68 **public** **void** throwRuntimeExceptionLineWhenExceptionIsThrown() { 69 CsvToBean<Object> bean = **new** CsvToBean<>(); 70 bean.setMappingStrategy(**new** ErrorLineMappingStrategy<>()); 71 bean.setCsvReader(createReader()); 72 Assertions.assertThrows(RuntimeException.**class**, () -> { 73 **for** (Object o : bean) { 74 } 75 }); 76 } 77 78 @Test 79 **public** **void** parseBeanWithNoAnnotations() { 80 HeaderColumnNameMappingStrategy<MockBean> strategy = **new** HeaderColumnNameMappingStrategy<>(); 81 strategy.setType(MockBean.**class**); 82 CsvToBean<MockBean> bean = **new** CsvToBean<>(); 83 bean.setMappingStrategy(strategy); 84 bean.setCsvReader(createReader()); 85 86 Iterator<MockBean> it = bean.iterator(); 87 assertTrue(it.hasNext()); 88 assertEquals(**new** MockBean("kyle", **null**, "abc123456", 123, 0.0), it.next()); 89 assertTrue(it.hasNext()); 90 assertEquals(**new** MockBean("jimmy", **null**, "def098765", 456, 0.0), it.next()); 91 assertFalse(it.hasNext()); 92 **try** { 93 it.next(); 94 fail("Iterator should have thrown an exception trying to access the element after the end of the list"); 95 } **catch** (NoSuchElementException e) {_/* Good. */_ 96 } 97 } 98 99 @Test 100 **public** **void** iteratorShouldNotSupportRemove() { 101 HeaderColumnNameMappingStrategy<MockBean> strategy = **new** HeaderColumnNameMappingStrategy<>(); 102 strategy.setType(MockBean.**class**); 103 CsvToBean<MockBean> bean = **new** CsvToBean<>(); 104 bean.setMappingStrategy(strategy); 105 bean.setCsvReader(createReader()); 106 107 Iterator<MockBean> it = bean.iterator(); 108 Assertions.assertThrows(UnsupportedOperationException.**class**, it::remove); 109 } 110 111 @Test 112 **public** **void** bug133ShouldNotThrowNullPointerExceptionWhenProcessingEmptyWithNoAnnotations() { ``` -------------------------------- ### build() Source: https://opencsv.sourceforge.net/jacoco/com.opencsv/CSVReaderHeaderAwareBuilder.java.html Creates the CSVReaderHeaderAware instance based on the set criteria. Throws RuntimeException if the header mapping cannot be initialized from the first line of data. ```APIDOC ## build() ### Description Creates the CSVReaderHeaderAware instance based on the set criteria. Throws RuntimeException if the header mapping cannot be initialized from the first line of data. ### Method build ### Returns - **CSVReaderHeaderAware** - The constructed CSVReaderHeaderAware instance. ### Throws - **RuntimeException** - If the header mapping cannot be initialized from the first line of data. ``` -------------------------------- ### build Source: https://opencsv.sourceforge.net/apidocs/com/opencsv/CSVReaderBaseBuilder.html Creates a new CSVReader instance. ```APIDOC ## build ### Description Must create the CSVReader type requested. ### Method GET ### Endpoint /build ### Parameters None ### Response #### Success Response (200) - **T** (object) - A new instance of `CSVReader` or derived class. #### Response Example ```json { "reader": {} } ``` ``` -------------------------------- ### CSV input for @CsvRecurse example Source: https://opencsv.sourceforge.net/index.html Example CSV input for the recursion example. The header row defines the columns, and the data row provides values for the title, author given name, author surname, publisher, and date fields. ```csv title,author given name,author surname,publisher,date Space Opera 2.0,Andrew,Jones,NoWay Publishers,3019 ``` -------------------------------- ### RowValidatorAggregator JUnit tests with row fixtures and parameterized sources Source: https://opencsv.sourceforge.net/xref-test/com/opencsv/validators/RowValidatorAggregatorTest.html The code block shows the beginning of a JUnit 5 test class for RowValidatorAggregator, ending mid-stream method createValidateArguments(). It defines test row fixtures, static validators leveraging RowFunctionValidator and RowMustHaveSameNumberOfColumnsAsFirstRowValidator, a @BeforeEach setup(), and two parameterized test methods (lineIsValid and the start of a second test method). The source is truncated in the HTML, so the remainder (including the end of createValidateArguments and the second test method) is not included. ```java 1 **package** com.opencsv.validators; 2 3 **import** com.opencsv.exceptions.CsvValidationException; 4 **import** org.junit.jupiter.api.Assertions; 5 **import** org.junit.jupiter.api.BeforeEach; 6 **import** org.junit.jupiter.api.DisplayName; 7 **import** org.junit.jupiter.api.Test; 8 **import** org.junit.jupiter.params.ParameterizedTest; 9 **import** org.junit.jupiter.params.provider.Arguments; 10 **import** org.junit.jupiter.params.provider.MethodSource; 11 12 **import** java.util.ArrayList; 13 **import** java.util.List; 14 **import** java.util.function.Function; 15 **import** java.util.stream.Stream; 16 17 **import** **static** org.junit.jupiter.api.Assertions.*; 18 **import** **static** org.mockito.Mockito.*; 19 20 **public** **class** RowValidatorAggregatorTest { 21 **private** **static** **final** String[] GOOD_ROW = {"8675309", "test@email.name"}; 22 **private** **static** **final** String[] ANOTHER_GOOD_ROW = {"1234567", "full.name@sourceforge.net"}; 23 **private** **static** **final** String[] BAD_ROW = {"not a number", "not.an.email"}; 24 **private** **static** **final** String[] LONG_ROW = {"2345678", "anemail@test.com", "extra column"}; 25 **private** **static** **final** String[] SHORT_ROW = {"7654321"}; 26 **private** **static** **final** String[] EMPTY_ROW = {}; 27 28 **private** RowValidatorAggregator aggregator; 29 30 **private** RowMustHaveSameNumberOfColumnsAsFirstRowValidator columnCountValidator; 31 32 **private** **static** **final** String FIRST_COLUMN_FAILURE_MESSAGE = "The first element of the row must be a seven digit number!"; 33 34 **private** **static** **final** Function<String[], Boolean> FIRST_ELEMENT_IS_A_NUMBER = 35 (x) -> x.length > 0 && x[0].matches("^[0-9]{7}$"); 36 **private** **static** **final** RowValidator FIRST_ELEMENT_VALIDATOR = **new** RowFunctionValidator(FIRST_ELEMENT_IS_A_NUMBER, FIRST_COLUMN_FAILURE_MESSAGE); 37 38 **private** **static** **final** String SECOND_COLUMN_FAILURE_MESSAGE = "The second element of the row must be an email address!"; 39 40 **private** **static** **final** Function<String[], Boolean> SECOND_ELEMENT_IS_AN_EMAIL_ADDRESS = 41 (x) -> x.length > 1 && x[1].matches("^([a-z0-9_\\.-]+)@([\\da-z\\.-]+)\\.([a-z\\.]{2,5})$"); 42 **private** **static** **final** RowValidator SECOND_ELEMENT_VALIDATOR = **new** RowFunctionValidator(SECOND_ELEMENT_IS_AN_EMAIL_ADDRESS, SECOND_COLUMN_FAILURE_MESSAGE); 43 44 45 @BeforeEach 46 **public** **void** setup() { 47 aggregator = **new** RowValidatorAggregator(); 48 49 columnCountValidator = **new** RowMustHaveSameNumberOfColumnsAsFirstRowValidator(); 50 } 51 52 _// A Note on the Arguments of the test. Because these variables are_ 53 _// recreated on each run each run has a new validator. That is why the_ 54 _// LONG_ROW has true for the column count validator result_ 55 _// because for each arguement it IS the first row. The SHORT_ROW fails_ 56 _// because there is not a second row to validate which is part of the validation regex._ 57 **private** **static** Stream<Arguments> createIsValidArguments() { 58 **return** Stream.of( 59 Arguments.of(GOOD_ROW, **true**), 60 Arguments.of(**null**, false), 61 Arguments.of(ANOTHER_GOOD_ROW, **true**), 62 Arguments.of(EMPTY_ROW, false), 63 Arguments.of(LONG_ROW, **true**), 64 Arguments.of(SHORT_ROW, false), 65 Arguments.of(BAD_ROW, false), 66 Arguments.of(GOOD_ROW, **true**) 67 ); 68 } 69 70 @DisplayName("RowValidatorAggregator isValid") 71 @ParameterizedTest 72 @MethodSource("createIsValidArguments") 73 **public** **void** lineIsValid(String[] row, **boolean** valid) { 74 aggregator.addValidator(**null**); 75 aggregator.addValidator(columnCountValidator); 76 aggregator.addValidator(FIRST_ELEMENT_VALIDATOR); 77 aggregator.addValidator(SECOND_ELEMENT_VALIDATOR); 78 79 assertEquals(valid, aggregator.isValid(row)); 80 } 81 82 83 _// A Note on the Arguments of the test. Because these variables are_ 84 _// recreated on each run each run has a new validator. That is why the_ 85 _// LONG_ROW and SHORT_ROW have true for the column count validator result_ 86 _// because for each arguement it IS the first row._ 87 **private** **static** Stream<Arguments> createValidateArguments() { 88 **return** Stream.of( 89 Arguments.of(GOOD_ROW, **true**, **true**, **true**), 90 Arguments.of(**null**, false, false, false), 91 Arguments.of(ANOTHER_GOOD_ROW, **true**, **true**, **true**), 92 ``` -------------------------------- ### MustStartWithACapitalLetter Class Source: https://opencsv.sourceforge.net/testapidocs/com/opencsv/bean/validators/MustStartWithACapitalLetter.html Documentation for the MustStartWithACapitalLetter class, including its constructor and methods. ```APIDOC ## MustStartWithACapitalLetter() ### Description Constructs a new instance of the MustStartWithACapitalLetter validator. ### Method Constructor ### Signature `public MustStartWithACapitalLetter()` ``` ```APIDOC ## isValid(String value) ### Description Checks whether the given string value starts with a capital letter. ### Method isValid ### Signature `public boolean isValid(String value)` ### Parameters - **value** (String) - Required - The string value to validate. ### Returns - **boolean** - `true` if the value starts with a capital letter, `false` otherwise. ``` ```APIDOC ## validate(String value, BeanField field) ### Description Validates that the given string value starts with a capital letter. Throws a CsvValidationException if validation fails. ### Method validate ### Signature `public void validate(String value, com.opencsv.bean.BeanField field) throws com.opencsv.exceptions.CsvValidationException` ### Parameters - **value** (String) - Required - The string value to validate. - **field** (com.opencsv.bean.BeanField) - Required - The bean field being validated. ### Throws - **com.opencsv.exceptions.CsvValidationException** - If the value does not start with a capital letter. ``` ```APIDOC ## setParameterString(String value) ### Description Sets a parameter string for the validator. This method is part of the StringValidator interface. ### Method setParameterString ### Signature `public void setParameterString(String value)` ### Parameters - **value** (String) - Required - The parameter string to set. ``` -------------------------------- ### Builder usage example Source: https://opencsv.sourceforge.net/jacoco/com.opencsv/RFC4180ParserBuilder.java.html Example code for using the RFC4180ParserBuilder class. It creates a parser with a tab separator by chaining withSeparator('\t') and build(). ```java final RFC4180Parser parser = new RFC4180ParserBuilder() .withSeparator(' ') .build(); ``` -------------------------------- ### build() Source: https://opencsv.sourceforge.net/jacoco/com.opencsv.bean/HeaderColumnNameMappingStrategyBuilder.java.html Builds and returns a HeaderColumnNameMappingStrategy instance with the configured options. ```APIDOC ## build() ### Description Builds and returns a HeaderColumnNameMappingStrategy instance with the configured options. ### Method build ### Endpoint HeaderColumnNameMappingStrategyBuilder.build() ### Parameters None ### Request Example ```java HeaderColumnNameMappingStrategy<MyBean> strategy = builder.build(); ``` ### Response #### Success Response - Returns a HeaderColumnNameMappingStrategy instance. #### Response Example ```java HeaderColumnNameMappingStrategy<MyBean> strategy = builder.build(); ``` ``` -------------------------------- ### prepare() Source: https://opencsv.sourceforge.net/apidocs/com/opencsv/bean/concurrent/LineExecutor.html Prepares this Executor to receive jobs. ```APIDOC ## prepare() ### Description Prepares this Executor to receive jobs. ### Method `public void prepare()` ### Parameters None. ### Returns void ``` -------------------------------- ### CSVParserBuilder usage example Source: https://opencsv.sourceforge.net/xref/com/opencsv/CSVParserBuilder.html Shows the fluent builder pattern for creating a CSVParser. The example is embedded in the Javadoc comment of the class and uses chained method calls to configure the parser. ```java final CSVParser parser = new CSVParserBuilder() .withSeparator(';') .withIgnoreQuotations(true) .build(); ``` -------------------------------- ### CSVWriterBuilder usage example Source: https://opencsv.sourceforge.net/jacoco/com.opencsv/CSVWriterBuilder.java.html Shows two ways to build an ICSVWriter: with a parser to create a CSVParserWriter, or with separator/quote/escape to create a CSVWriter. The example is from the class Javadoc and demonstrates the builder pattern. ```java Writer writer = new StringWriter(); // any Writer CSVParser parser = new CSVParserBuilder().build(); ICSVWriter csvParserWriter = new CSVWriterBuilder(writer) .withParser(parser) .withLineEnd(ICSVWriter.RFC4180_LINE_END) .build(); // will produce a CSVParserWriter ICSVWriter csvWriter = new CSVWriterBuilder(writer) .withSeparator(ICSVParser.DEFAULT_SEPARATOR) .withQuoteChar(ICSVParser.DEFAULT_QUOTE_CHARACTER) .withEscapeChar(ICSVParser.DEFAULT_ESCAPE_CHARACTER) .withLineEnd(ICSVWriter.DEFAULT_LINE_END) .build(); // will produce a CSVWriter ``` -------------------------------- ### build() Source: https://opencsv.sourceforge.net/jacoco/com.opencsv.bean/FuzzyMappingStrategyBuilder.java.html Builds and returns a FuzzyMappingStrategy instance with the configured settings. ```APIDOC ## Method: build() ### Description Builds a new FuzzyMappingStrategy instance. If a type was set, it is assigned to the strategy. The strategy is configured with the forceCorrectRecordLength setting. ### Method build ### Endpoint `FuzzyMappingStrategy<T> build()` ### Parameters None ### Request Example ```java FuzzyMappingStrategy<MyBean> strategy = builder.build(); ``` ### Response #### Success Response - **FuzzyMappingStrategy<T>** - The built mapping strategy. #### Response Example ```java FuzzyMappingStrategy<MyBean> strategy = builder.build(); ``` ``` -------------------------------- ### build() Source: https://opencsv.sourceforge.net/jacoco/com.opencsv/RFC4180ParserBuilder.java.html Constructs a new RFC4180Parser with the configured settings. ```APIDOC ## build() ### Description Builds and returns a new RFC4180Parser instance using the current builder settings. ### Method Build ### Signature `public RFC4180Parser build()` ### Parameters None ### Returns - **RFC4180Parser** - A new parser with the configured separator, quote character, and null field indicator. ``` -------------------------------- ### Input header names for fuzzy mapping example Source: https://opencsv.sourceforge.net/index.html Example CSV header row used with the FuzzyMappingStrategy. Contains headers that will be matched to bean fields, including a misspelled header 'mispeling'. ```text joined header 1,joined header 2,split header,first header,second header,mispeling ``` -------------------------------- ### RowFunctionValidatorTest example: GOOD_ROW constant Source: https://opencsv.sourceforge.net/apidocs/com/opencsv/validators/RowFunctionValidator.html Declares a sample row used by the validator examples. The row contains an ID, first name, middle initial, last name, and a date string. ```java private static final String[] GOOD_ROW = {"8675309", "Firstname", "M", "Lastname", "Dec 06, 1951"}; ``` -------------------------------- ### run() Source: https://opencsv.sourceforge.net/apidocs/com/opencsv/bean/concurrent/CompleteFileReader.html Runs a tight loop to read input and submit it for conversion. This method is specified by the Runnable interface. ```APIDOC ## Method: run ### Description Runs a nice, tight loop to simply read input and submit for conversion. ### Signature ```java public void run() ``` ### Specified By - `run` in interface `Runnable` ``` -------------------------------- ### build() Source: https://opencsv.sourceforge.net/apidocs/com/opencsv/bean/StatefulBeanToCsvBuilder.html Builds a StatefulBeanToCsv from the information provided, filling in default values where none have been specified. ```APIDOC ## Method: build() ### Description Builds a StatefulBeanToCsv from the information provided, filling in default values where none have been specified. ### Returns StatefulBeanToCsv<T> - The built StatefulBeanToCsv instance ``` -------------------------------- ### get(K key) Source: https://opencsv.sourceforge.net/apidocs/com/opencsv/bean/AbstractFieldMap.html Gets the BeanField associated with the given key. Simple keys are always matched before complex keys, and if a key matches multiple complex keys, the return value is undefined. ```APIDOC ## get(K key) ### Description Gets the `BeanField` associated with this key. If a key could possibly match both a regular, simple key (one added with `FieldMap.put(Comparable, BeanField)`), and a complex key (one added with `FieldMap.putComplex(java.lang.Object, com.opencsv.bean.BeanField)`), the simple key is always matched. If a key could match more than one complex key, the return value is undefined. ### Method GET ### Parameters #### Path Parameters - **key** (K) - Required - The key under which to search for a `BeanField` ### Returns - **BeanField<T,K>** - The `BeanField` found, or null if none is present ``` -------------------------------- ### getFieldValue Source: https://opencsv.sourceforge.net/apidocs/com/opencsv/bean/BeanField.html Gets the contents of the selected field of the given bean. This method performs no conversions of any kind, but simply gets the value of the desired field using an accessor method if one is available and reflection if one is not. ```APIDOC ## `Object getFieldValue(Object bean)` ### Description Gets the contents of the selected field of the given bean. This method performs no conversions of any kind, but simply gets the value of the desired field using an accessor method if one is available and reflection if one is not. ### Method `getFieldValue` ### Parameters - `bean` (Object) - Required - Object containing the field to be read ### Returns The value of the field in the given bean. ### Since 4.2 ``` -------------------------------- ### CSVReaderHeaderAwareBuilder Methods Source: https://opencsv.sourceforge.net/xref/com/opencsv/CSVReaderHeaderAwareBuilder.html Builder methods for configuring a CSVReaderHeaderAware instance. ```APIDOC ## CSVReaderHeaderAwareBuilder(Reader reader) ### Description Constructs a new builder with the specified reader as the underlying CSV source. ### Method Constructor ### Parameters - **reader** (Reader) - Required - The reader to an underlying CSV source. ### Returns A new CSVReaderHeaderAwareBuilder instance. ``` ```APIDOC ## withSkipLines(int skipLines) ### Description Sets the number of lines to skip before reading. ### Method withSkipLines ### Parameters - **skipLines** (int) - Required - The number of lines to skip before reading. ### Returns This builder instance. ``` ```APIDOC ## withCSVParser(ICSVParser icsvParser) ### Description Sets the parser to use to parse the input. ### Method withCSVParser ### Parameters - **icsvParser** (ICSVParser) - Required - The parser to use to parse the input. ### Returns This builder instance. ``` ```APIDOC ## withKeepCarriageReturn(boolean keepCR) ### Description Sets if the reader will keep or discard carriage returns. ### Method withKeepCarriageReturn ### Parameters - **keepCR** (boolean) - Required - True to keep carriage returns, false to discard. ### Returns This builder instance. ``` ```APIDOC ## withVerifyReader(boolean verifyReader) ### Description Checks to see if the CSVReaderHeaderAware should verify the reader state before reads or not. This should be set to false if you are using some form of asynchronous reader (like readers created by the java.nio.* classes). The default value is true. ### Method withVerifyReader ### Parameters - **verifyReader** (boolean) - Required - True if CSVReaderHeaderAware should verify reader before each read, false otherwise. ### Returns This builder instance. ``` ```APIDOC ## withFieldAsNull(CSVReaderNullFieldIndicator indicator) ### Description Checks to see if it should treat a field with two separators, two quotes, or both as a null field. ### Method withFieldAsNull ### Parameters - **indicator** (CSVReaderNullFieldIndicator) - Required - Set to what should be considered a null field. ### Returns This builder instance. ``` ```APIDOC ## withMultilineLimit(int multilineLimit) ### Description Sets the maximum number of lines allowed in a multiline record. More than this number in one record results in an IOException. ### Method withMultilineLimit ### Parameters - **multilineLimit** (int) - Required - No more than this number of lines is allowed in a single input record. The default is CSVReader.DEFAULT_MULTILINE_LIMIT. ### Returns This builder instance. ``` ```APIDOC ## withErrorLocale(Locale errorLocale) ### Description Sets the locale for all error messages. ### Method withErrorLocale ### Parameters - **errorLocale** (Locale) - Required - Locale for error messages. ### Returns This builder instance. ``` ```APIDOC ## withLineValidator(LineValidator lineValidator) ### Description Adds a LineValidator to the CSVReaderHeaderAware. Multiple LineValidators can be added with multiple calls. ### Method withLineValidator ### Parameters - **lineValidator** (LineValidator) - Required - LineValidator to inject. ### Returns This builder instance. ``` -------------------------------- ### getInitializer() Source: https://opencsv.sourceforge.net/apidocs/com/opencsv/bean/ComplexFieldMapEntry.html Returns the information used to initialize this entry. This information is not guaranteed to be exactly the same as the original value, but is functionally equivalent. ```APIDOC ## getInitializer() ### Description Returns the information used to initialize this entry. This information is not guaranteed to be exactly the same as the original value, but is functionally equivalent. ### Method getInitializer ### Returns The original information used to initialize this mapping entry ``` -------------------------------- ### getBean() Source: https://opencsv.sourceforge.net/apidocs/index-all.html Gets the bean that was to be introspected. ```APIDOC ## getBean() ### Description Gets the bean that was to be introspected. ### Method getBean() ### Returns - **Object** - The bean that was to be introspected. ``` -------------------------------- ### getException() Source: https://opencsv.sourceforge.net/apidocs/com/opencsv/ICSVWriter.html Get latest exception. ```APIDOC ## getException ### Description Get latest exception. ### Returns IOException - the latest exception ``` -------------------------------- ### CSVReader.readAll() Source: https://opencsv.sourceforge.net/jacoco/com.opencsv/CSVReader.java.html Reads the entire file into a List with each element being a String[] of tokens. ```APIDOC ## CSVReader.readAll() ### Description Reads the entire file into a List with each element being a String[] of tokens. Since the current implementation returns a LinkedList, you are strongly discouraged from using index-based access methods to get at items in the list. Instead, iterate over the list. ### Method GET ### Endpoint CSVReader.readAll() ### Parameters None ### Response #### Success Response - **List<String[]>** - A List of String[], with each String[] representing a line of the file. #### Response Example ```java List<String[]> allElements = csvReader.readAll(); ``` ### Error Handling - **IOException** - If bad things happen during the read - **CsvException** - If there is a failed validator ``` -------------------------------- ### BlankColumnsBecomeNull() Source: https://opencsv.sourceforge.net/testapidocs/com/opencsv/processor/BlankColumnsBecomeNull.html Constructor for the BlankColumnsBecomeNull class. Initializes a new instance of the processor. ```APIDOC ## BlankColumnsBecomeNull() ### Description Constructor for the BlankColumnsBecomeNull class. Initializes a new instance of the processor. ### Method Constructor ### Endpoint N/A (Java constructor) ### Parameters None ### Request Example ```java BlankColumnsBecomeNull processor = new BlankColumnsBecomeNull(); ``` ### Response #### Success Response - No return value (constructor) #### Response Example N/A ``` -------------------------------- ### Example CSV inputs from customer 1 and customer 2 Source: https://opencsv.sourceforge.net/index.html Two example CSV inputs from different customers that contain the same data but use different column names and formats. They are used to illustrate the need for profiles in opencsv. ```csv last name,first name,middle initial,salary,height Jones,Andrew,R,50000.00,188 ``` ```csv surname,given name,annual salary,height Jones,Andrew,5.0E5,188cm ``` -------------------------------- ### StatefulBeanToCsvBuilder.build() Source: https://opencsv.sourceforge.net/apidocs/com/opencsv/bean/class-use/StatefulBeanToCsv.html Documentation for the build() method of StatefulBeanToCsvBuilder, which returns a StatefulBeanToCsv instance. ```APIDOC ## StatefulBeanToCsvBuilder.build() ### Description Builds a StatefulBeanToCsv from the information provided, filling in default values where none have been specified. ### Method build() ### Return Type StatefulBeanToCsv<T> ### Usage This method is part of the StatefulBeanToCsvBuilder class in the com.opencsv.bean package. It constructs a StatefulBeanToCsv instance using the builder's configuration, applying defaults for unspecified settings. ``` -------------------------------- ### Input file for custom converter example Source: https://opencsv.sourceforge.net/index.html Input file for the custom converter example. Contains a header row and two data rows. The nodes column is space-delimited and the production column uses German boolean values (wahr/falsch). ```text cluster,nodes,production cluster1,node1 node2,wahr cluster2,node3 node4 node5,falsch ``` -------------------------------- ### HeaderColumnNameMappingStrategyBuilder() Source: https://opencsv.sourceforge.net/jacoco/com.opencsv.bean/HeaderColumnNameMappingStrategyBuilder.java.html Default constructor for the builder. ```APIDOC ## HeaderColumnNameMappingStrategyBuilder() ### Description Default constructor for the builder. ### Method Constructor ### Endpoint HeaderColumnNameMappingStrategyBuilder() ### Parameters None ### Request Example ```java HeaderColumnNameMappingStrategyBuilder<MyBean> builder = new HeaderColumnNameMappingStrategyBuilder<>(); ``` ### Response #### Success Response - Returns a new instance of the builder. #### Response Example ```java HeaderColumnNameMappingStrategyBuilder<MyBean> builder = new HeaderColumnNameMappingStrategyBuilder<>(); ``` ``` -------------------------------- ### getBeanClass() Source: https://opencsv.sourceforge.net/apidocs/index-all.html Gets the class of the bean to which the value was to be assigned. ```APIDOC ## getBeanClass() ### Description Gets the class of the bean to which the value was to be assigned. ### Method getBeanClass() ### Returns - **Class<?>** - The class of the bean. ```