Exporting empty csv in SSRS from data driven subscription - csv

How do I remove the commas from an exported csv file created from an SSRS (2012) data driven subscription when the data returned is empty? The report is created daily then exported as a csv file. When the report returns no results the csv file exported consists of one line of commas only. When it does return results it outputs a proper csv file. The file needs to be generated daily regardless of the results but needs to be empty without the commas when no data is returned?
e.g. when data is returned:
Name1, Address1, City1, State1, Zip1
Name2, Address2, City2, State2, Zip2
e.g. when data is not returned I need it to be blank but it currently creates:
,,,,

Related

While Import Data from Excel to SQL DB SSIS Shows NULL for Interger Columns

I am using an Excel file to import data in the SQL DB Table.
My column contains Both Text and Interger data types.
While Previewing my Excel file in SSIS Excel Source Assistant it shows NULL for that Integer Rows.
Note: I don't need change any columns in the Excel file.
Can we achieve this in SSIS itself?
The Excel driver reads a certain number of rows (by default, 8 rows) in the specified source to guess at the data type of each column. When a column appears to contain mixed data types, especially numeric data mixed with text data, the driver decides in favor of the majority data type, and returns null values for cells that contain data of the other type.
So, regarding this issue, this behavior is by design. To address this issue, we add IMEX=1 to the value of Extended Properties in the connection string of the Excel connection manager in the Properties window.
For .xlsx file, the connection string of the Excel Connection Manager is like:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Temp\Test.xlsx;Extended Properties="Excel 12.0 XML;HDR=YES;IMEX=1";
For .xls file, the connection string of the Excel Connection Manager is like:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Temp\Test.xls;Extended Properties="Excel 8.0;HDR=YES;IMEX=1";

Data conversion from DT_STR to Currency to load with in 2 destinations

I have a data flow task that consists of loading data from a flat file source (Products.csv) to transfer them to:
Staging table: to save valid data
InvalidRows: a flat file destination to save invalid data
The data that I need to load are shown in the screenshot.
So, my data conversion component allows to convert 2 attributes: ProductID and Price (as shown in the screenshot).
I'm sure that the result should be as follows:
Staging table: contains the two products where ID=4 and ID=6
InvalidRows: contains the product where ID=5
When executing, I get the following result:
"The value could not be converted because of a potential loss of
data."
which is caused by the price column that should be converted from DT_STR to DT_CY.
It's a conversion problem, and I tried many things (data conversion / derived column), but without success.

SSIS formatting Currency Output

In my output CSV file I have 4 columns that are Data Type Currency. My output is a Flat File CSV file.
I would like every column in the output to be of the format $####.##
This is not happening. Columns in the output CSV file that actually have cents are appearing 50.79 (no $), columns that end in 0 are suppressing the 0 (40.8) and columns that are zero are appearing as simply 0.
In the CSV file that I am using for my Flat File Destination Connection Manager I have formatted the 4 columns as currency and in SSIS I have formatted the 4 columns as currency.
Can someone show me how to accomplish what I want?
Thanks
If you don't want the cents suppressed, your format should be:
$0.00
If you want thousand separators:
$#,##0.00

Mistmatch between Socrata JSON and CSV metadata

There is a mismatch between the columns defined in the JSON metadata and the CSV data for a dataset.
For example, the metadata listing shows the columns - name, address1, address2, city, ...
https://data.montgomerycountymd.gov/api/views/ecam-8hbr.json
But the CSV listing has address1, address2, category, city, ...
https://data.montgomerycountymd.gov/resource/ecam-8hbr.csv?$limit=2&$offset=0
It's not that they don't match, the fields are just presented in different orders.
The CSV lists the columns in alphabetical order:
"address1","address2","category",...,"zip"
Whereas the JSON metadata lists the fields in the same order that the dataset was originally defined (when data was first uploaded). Look at the dataset in the Web UI, the fields are in the same order as the JSON metadata. Note the location column in the dataset is broken out into component columns in the export.
"name","address1",...,"location","location_city","location_address","location_zip","location_state"
Both representations have the same 34 standard fields. The JSON metadata includes an additional 4 fields that appear to be computed and related to other datasets, so not included in the CSV export.

ssrs 2008 r2 export to csv displays column all the time

In an SSRS 2008 R2 report, the users are going to export the data to: csv (comma delimited) and excel.
I am using the following to display if a column is visible or not:
=IIF(Mid(Globals!RenderFormat.Name,1,5)="EXCEL" AND First(Len(Fields!CustomerNumber.Value)) > 0,False,true)
I have set the DataElementOutput=Output for the textbox that displays the value.
I have left DataElementOutput=Auto for the textbox that contains the column header.
When exporting to csv (comma delimited) or excel, I basically want the column to be visible when there is data in the field and the column not to be visible when there is no data.
The code works for excel but the code does not work for comma delimited.
Thus, can you tell me what I can do so the column is not disaplyed when the data is exported to csv (comma delimited)?
You may attempt to do this with a continuation of statement accounting for the "CSV" output type.
=IIF( (Mid(Globals!RenderFormat.Name,1,5)="EXCEL" OR Mid(Globals!RenderFormat.Name,1,5)="CSV") AND First(Len(Fields!CustomerNumber.Value)) > 0,False,true)
Or a switch statement:
=Switch(Mid(Globals!RenderFormat.Name,1,5)="EXCEL" AND First(Len(Fields!CustomerNumber.Value)) > 0,False, Mid(Globals!RenderFormat.Name,1,5)="CSV" AND First(Len(Fields!CustomerNumber.Value)) > 0,False,true)
However....
The problem may be due to the nature of a csv file being a simpler format that cannot handle this in output. It depends on how SSRS handles the output if it is hard writing the output before the write operation. It may simply not work because of the limitations of the format of CSV. If this was the case you may be able to simple take the Excel output and save it to CSV either in code or a manual operation.