[ 
https://issues.apache.org/jira/browse/CSV-304?focusedWorklogId=807060&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-807060
 ]

ASF GitHub Bot logged work on CSV-304:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 08/Sep/22 15:00
            Start Date: 08/Sep/22 15:00
    Worklog Time Spent: 10m 
      Work Description: pedro-w commented on PR #257:
URL: https://github.com/apache/commons-csv/pull/257#issuecomment-1240838646

   > 
   
   
   > Is the intent to allow comments at the start and end of a file or before 
and after each record?
   
   The former. I'll explain my thinking, *please correct me if I've got it 
wrong!*
   
       ; Comment 0
       A,B
       ; Comment 1
       1,1
       ; Comment 2
       2,2
       ; Comment 3
   
   The comments attach to the following line so Comments 1 & 2 can currently be 
extracted from the corresponding `CSVRecord`s and Comment 3 can never be 
accessed. Comment 0 is a special case. If we ask `CSVParser` to generate the 
column headings from the first record, it can't be accessed, but otherwise it's 
attached to "A,B" which is just a normal data record.
   
   My intention was to allow access to Comment 0 via `getHeaderComment` (only 
in the case of generated column names) and Comment 3 via `getTrailerComment` 
(always).
   
   
   I'll get onto the other issues too as they're mostly just formatting.
   




Issue Time Tracking
-------------------

    Worklog Id:     (was: 807060)
    Time Spent: 1h  (was: 50m)

> Provide access methods for header and trailer comments
> ------------------------------------------------------
>
>                 Key: CSV-304
>                 URL: https://issues.apache.org/jira/browse/CSV-304
>             Project: Commons CSV
>          Issue Type: Improvement
>          Components: Parser
>    Affects Versions: 1.9.0
>            Reporter: Peter Hull
>            Priority: Minor
>             Fix For: Discussion
>
>         Attachments: header-comment.patch
>
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> The Apache Commons CSV library can deal with comments by attaching the 
> comment to the following record.
> It does not seem possible to access comments that are before the header line 
> ("header comments"), or after the last record ("trailer comments")
> I feel this would be a useful enhancement to the current comment-handling 
> features of version 1.9.
> I have not been able to find mention of this in other JIRA tickets.
> I have attached a patch implementing this, for discussion purposes. (n.b. I 
> had trouble with git showing spurious ^M at the end of changed lines in 
> CSVParserTest.java which I could not get rid of)
> This adds methods String CSVParser::getHeaderComment(), String 
> CSVParser::getTrailerComment(), bool CSVParser::hasHeaderComment() and bool 
> CSVParser::hasTrailerComment() . The last two could be omitted assuming a 
> missing comment would return a null String.
>  
> See also 
> [https://stackoverflow.com/questions/72619095/get-leading-comments-from-csv-with-apache-commons-csv]
>  and [https://lists.apache.org/thread/8tczpqlnjgbcyovyhb484tt11vqv91jt]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to