Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 3
    are you always going to want a consecutive set of columns (e.g. 2-7, or 5-15 or whatever)? if so, you can use a loop to print the columns. If not, there's no avoiding listing the individual columns you want (although you can mix in some loops where needed). Also, how many columns? Commented Jul 29, 2019 at 2:07
  • 1
    Finally, you might want to consider a language like perl or python with a good CSV parser....especially if you have the column names in the first line (several of perl's CSV parsing modules can use these to construct a hash with the column names as keys. i'm pretty sure python's CSV parsers can do similar). perl also has excellent array & hash splicing operators. Commented Jul 29, 2019 at 2:09
  • @cas yes the columns would be always consecutive. Commented Jul 29, 2019 at 13:55
  • 1
    Does this answer your question? Print range of columns comma-separated, and the rest without comma-separation Commented Jan 13, 2021 at 15:18
  • Also on StackOverflow Commented Mar 14, 2023 at 19:38