Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,551,726
Community Members
 
Community Events
184
Community Groups

how to read from a CSV file using Groovy script .

Hello ,

 

I am trying to read a CSV file which has two columns 

issue_key | custom_filed_value 

i am trying to get the value of key and value using groovy script so that i can update the issue key got from the CSV .

Any help is highly appreciated .

Abyakta

4 answers

I have used Super CSV to read data but in confluence.

Should work in Jira too

https://super-csv.github.io/super-csv/examples_reading.html

Also it is good idea to run dos2unix if you have it in Linux to fix format and encoding.

 

// Misc manipulations
import java.nio.charset.StandardCharsets

// CSV Imports - http://super-csv.github.io/super-csv/index.html
import org.supercsv.io.CsvBeanReader
import org.supercsv.io.CsvMapReader
import org.supercsv.prefs.CsvPreference
import org.supercsv.cellprocessor.CellProcessorAdaptor
import org.supercsv.cellprocessor.ift.CellProcessor
import org.supercsv.cellprocessor.Optional

def csvFile="/some/path/csvFile.csv"
// as in https://super-csv.github.io/super-csv/apidocs/org/supercsv/prefs/CsvPreference.html
CsvPreference PIPE_DELIMITED = new CsvPreference.Builder('"', '|', "\n").build()

def mapReader = new CsvMapReader(new InputStreamReader(new FileInputStream(localFilePath), StandardCharsets.UTF_8), PIPE_DELIMITED)

def header = mapReader.getHeader(true)

while ( (issuesMap = mapReader.read(header)) != null ) {

def issueKey = issuesMap."issue_key" def cfValue = issuesMap."custom_filed_value"
// Rest is to find issue by Key in Jira and use mutable Issue and CF Manager to set CF value
}

 

Same problem here...anyone to help us?

Also am interested in this.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events