zhangqs0205 opened a new issue, #10476:
URL: https://github.com/apache/seatunnel/issues/10476

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22bug%22)
 and found no similar issues.
   
   
   ### What happened
   
   # Description:
   ## Bug Description
   When parsing CSV data that contains escape characters (e.g., \"), the CSV 
parser fails to correctly parse the line and returns all fields as null instead 
of the actual values.
   
   ## Affected Component
   Module: seatunnel-format-text
   Class: CsvLineSplitor
   Steps to Reproduce
   Read a CSV file containing fields with escaped quotes, for example:
   ```
   String line = "1, name: \\\"tyrantlucifer\\\""
   ```
   Parse the CSV line using the CsvLineSplitor
   Observe that all fields are returned as null
   Expected Behavior
   The parser should correctly handle escape characters and return:
   
   Field 1: 1
   Field 2: name: "tyrantlucifer"
   Actual Behavior
   All fields are returned as null.
   
   ## Root Cause
   The CSVFormat configuration in CsvLineSplitor.java does not specify an 
escape character. When the Apache Commons CSV parser encounters a backslash (\) 
without a configured escape character, it fails to parse the line correctly.
   
   ## Solution
   Configure the CSVFormat to explicitly set the escape character to backslash:
   
   ```java
   CSVFormat.DEFAULT.builder().setDelimiter(splitChar).setEscape('\\').build()
   ```
   
   ### SeaTunnel Version
   
   2.3.9
   
   ### SeaTunnel Config
   
   ```conf
   env {
     parallelism = 1
     job.mode = "BATCH"
   }
   
   source {
     FtpFile {
       host = "127.0.0.1"
       port = 21
       user = "user"
       password = "123"
       path = "/path/to/csv/file"
       file_format_type = "text"
       delimiter = ","
       schema = {
         fields {
           index_field = int
           desc_field = string
         }
       }
     }
   }
   
   sink {
     Console {
     }
   }
   ```
   
   ### Running Command
   
   ```shell
   seatunnel.sh -c run.conf -m local
   ```
   
   ### Error Exception
   
   ```log
   print all column is null
   ```
   
   ### Zeta or Flink or Spark Version
   
   _No response_
   
   ### Java or Scala Version
   
   _No response_
   
   ### Screenshots
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to