Menu
Download Free Trial

How can i avoid adding d+ prefix for non date column

I am using flexmonster compressor for csv datasource with datasourcetype as “ocsv” .After compression of the csv,I found some non date column also starts with d+ prefix

Compressor code:-
String destPath = outputService.getCsv( processId,
localeCode, "CSV", reportId, clientId,false);
String reportName = rs.getReportNames(new Long(reportId), localeCode);
InputStream inputStream = com.flexmonster.compressor.Compressor.compressFile(destPath);
response.setContentType("text/plain");
OutputStream outputStream = response.getOutputStream();
int length = 0;
byte[] buffer = new byte[10240];
while ((length = inputStream.read(buffer)) > 0) {
outputStream.write(buffer, 0, length);
outputStream.flush();
}
outputStream.close();
inputStream.close();

Html code:-
var pivot = $("#pivotContainer").flexmonster({
componentFolder:"../js/flexmonster/",
toolbar: true,
showGrandTotals :false,
report: {
dataSource: {
dataSourceType: "ocsv",
filename: csv compressor url
fieldSeparator: ',',
ignoreQuotedLineBreaks: false
});

csv compressor output:
+Customername,-Order Year,-Sale Price,+Status,+Product Line,+Sales Person,-Customernumber,d+Product Name,d+Order Date
Atelier graphique,2003,3138.46,Shipped,Classic Cars,Hernandez,103,-152668800,1053388800
^0,2003,5282.64,^0,^0,^0,103,1999 Indy 500 Monte Carlo SS,1053388800
^0,2003,3986.84,^0,^0,^0,103,1948 Porsche Type 356 Roadster,1053388800
^0,2003,2163.5,^0,^0,^0,103,1966 Shelby Cobra 427 S/C,1053388800
^0,2004,4128.54,^0,Motorcycles,^0,103,1996 Moto Guzzi 1100i,1096243200
^0,2004,1938.24,^0,^1,^0,103,1936 Harley Davidson El Knucklehead,1096243200
^0,2004,1676.14,^0,Vintage Cars,^0,103,1938 Cadillac V-16 Presidential Limousine,1101340800
Signal Gift Stores,2003,3213,^0,^2,Thompson,112,1917 Grand Touring Sedan,1053475200

7 answers

Public
Tanya Gryshko Flexmonster April 5, 2017

Hello Manoranjan,
Thank you for your question. Could you please specify which database you use?
Regards,
Tanya

Public
Manoranjan Gahana April 6, 2017

Hi Tanya,
Thank you for your response.
I am using MySQL database
 
Regards,
Manoranjan

Public
Tanya Gryshko Flexmonster April 6, 2017

Hi Manoranjan,

Could you please check the data type of this field in your database? Flexmonster compressor uses table’s metadata to define data types. So most probably you have a timestamp or any other date-like type in the mentioned field.

Thanks,
 Tanya

Public
Manoranjan Gahana April 7, 2017

Hi Tanya,
       In our case we are not communicating with database.we are just passing csv file to compressFile().
       Could please clarify my doubt ?
       When we are passing csv file directly as input.How its differentiating which are date datatype or number datatype or text datatype ?

package com.test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
public class FlexMonsterCompressor {
public static void main(String[] args) {
try {
String destPath = “E:\\tmp\\output\\262.csv”;
InputStream inputStream = com.flexmonster.compressor.Compressor
.compressFile(destPath);
OutputStream outputStream = new FileOutputStream(new File(
“test.txt”));
int length = 0;
byte[] buffer = new byte[10240];
while ((length = inputStream.read(buffer)) > 0) {
outputStream.write(buffer, 0, length);
outputStream.flush();
}
outputStream.close();
System.out.println(“compressed….”);
} catch (Exception e) {
e.printStackTrace();
}
}
}
 
Input CSV:-
Customername,Order Year,Sale Price,Status,Product Line,Sales Person,Product Name,Customernumber,Order Date
Atelier graphique,2003,3138.46,Shipped,Classic Cars,Hernandez,1965 Aston Martin DB5,103,05/20/2003
Atelier graphique,2003,5282.64,Shipped,Classic Cars,Hernandez,1999 Indy 500 Monte Carlo SS,103,05/20/2003
Atelier graphique,2003,3986.84,Shipped,Classic Cars,Hernandez,1948 Porsche Type 356 Roadster,103,05/20/2003
Atelier graphique,2003,2163.5,Shipped,Classic Cars,Hernandez,1966 Shelby Cobra 427 S/C,103,05/20/2003
Atelier graphique,2004,4128.54,Shipped,Motorcycles,Hernandez,1996 Moto Guzzi 1100i,103,09/27/2004
 
ouput csv:-
___ocsv2___2.312/2.213
+Customername,-Order Year,-Sale Price,+Status,+Product Line,+Sales Person,d+Product Name,-Customernumber,d+Order Date
Atelier graphique,2003,3138.46,Shipped,Classic Cars,Hernandez,1488326400,103,1053388800
^0,2003,5282.64,^0,^0,^0,Indy 500 Monte Carlo SS,103,1053388800
^0,2003,3986.84,^0,^0,^0,Porsche Type 356 Roadster,103,1053388800
 
In the above input csv the Product Name column having data which is starts with year(see the highlighted portion).
If i am removing year & DB5 from csv then its working for me.
Could you please look into this issue ASAP.
 
Regards,
Manoranjan

Public
Tanya Gryshko Flexmonster April 7, 2017

Hello Manoranjan,
Thank you for providing the detailed explanation. As a workaround, we suggest you replace Product Name with +Product Name in the input CSV file. This way you just specify Product Name as a dimension explicitly.
Regards,
Tanya

Public
Manoranjan Gahana April 7, 2017

Hi Tanya,
In our case we cann’t modify the compressed csv,because we are directly writing the compressed csv output into the HttpServletResponse like below.
 
InputStream inputStream = com.flexmonster.compressor.Compressor.compressFile(destPath);
InputStream inputStream =new FileInputStream(destPath);
response.setContentType(“text/plain”);
OutputStream outputStream = response.getOutputStream();
int length = 0;
byte[] buffer = new byte[10240];
while ((length = inputStream.read(buffer)) > 0) {
outputStream.write(buffer, 0, length);
outputStream.flush();
}
outputStream.close();
inputStream.close();

Public
Tanya Gryshko Flexmonster April 7, 2017

Hello Manoranjan,
Please note that we suggest you modify the input CSV file, not the compressed one.
Regards,
Tanya

Please login or Register to Submit Answer