How to change data type when export to CSV file?

English! place to talk about development, programming and coding
Post Reply
ohmygoh
Znuny newbie
Posts: 8
Joined: 07 Jun 2012, 03:10
Znuny Version: OTRS 3.1

How to change data type when export to CSV file?

Post by ohmygoh »

Hi,

When i try to export Search report to CSV, in the popup search box i choose "Ticket Number" from "Add another attribute:" dropdown list, what if i want to change the data type of "Ticket Number" to Text/String instead of Integer?

Thanks.

Reagrds
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: How to change data type when export to CSV file?

Post by jojo »

CSV does not know these data types, you Excel is interpreting it as a number.

Rename file to .txt and import it, Excel should now ask
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
ohmygoh
Znuny newbie
Posts: 8
Joined: 07 Jun 2012, 03:10
Znuny Version: OTRS 3.1

Re: How to change data type when export to CSV file?

Post by ohmygoh »

Hi jojo,

This is one of the solution, but i believe users might not want to to do all the time. So i want to change the field to "String" when export to CSV file. So users do not need to do the rename work.

Sometimes the integer field will auto convert from 123456789 to 1.01206E+15 in Excel.

Thanks.
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: How to change data type when export to CSV file?

Post by jojo »

CSV has no field types
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
ohmygoh
Znuny newbie
Posts: 8
Joined: 07 Jun 2012, 03:10
Znuny Version: OTRS 3.1

Re: How to change data type when export to CSV file?

Post by ohmygoh »

Hi Jojo,

Ya, i knew. So i think i need to change the source code to customise it. before convert array to CVS, i might need to "hardcode" Ticket number as String data types.
Just do not know how to code it using Perl.

Thanks.
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: How to change data type when export to CSV file?

Post by jojo »

the numer appears correctly in CSV file. YOu Excel interprets it. It needs to be solved in your spreadsheetsoftware (Excel)
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
ohmygoh
Znuny newbie
Posts: 8
Joined: 07 Jun 2012, 03:10
Znuny Version: OTRS 3.1

Re: How to change data type when export to CSV file?

Post by ohmygoh »

Hi jojo,

Yes, i can change the format manually thru Excel, but i dont want users to do it manually.
Currentlly when export to CVS, the value of Ticket number will become 1.04205E+15 instead of 104205251000010

How to disable the autoformat in excel? Because i cant find the solution in Excel, that is why i am thinking to change the source code.


Thanks.
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: How to change data type when export to CSV file?

Post by jojo »

Rename file to .txt and import it, Excel should now ask


Or use Open Office
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
ohmygoh
Znuny newbie
Posts: 8
Joined: 07 Jun 2012, 03:10
Znuny Version: OTRS 3.1

Re: How to change data type when export to CSV file?

Post by ohmygoh »

Hi jojo,

Ya it works if rename the extension, but i prefer is to provide management users a proper report.
Means they do not need to go thru the CSV wizard.
The simplest way to that is change the Ticket Number data type to String from Integer.
Or,
There is a "on/off" in Excel, not to auto format the value of Ticket Number.

Any idea?

Thanks.
Post Reply