Want a CSV file as an output.
I am spending sleepless nights to solve this problem at last i have to decided to surrender.Lets see who will help me to get my sleep back.
I have got a file in the following format
User
|
--- 100009 Amarendra Choudhury
|
|-- T-D1450013 <PRO> Profile for role Z:COMMON_AUTH
| |
| |-- S_BDS_DS <OBJ> BC-SRV-KPR-BDS: Authorizations for Document Set
| | |
| | --- T-D145001300 <AUT> BC-SRV-KPR-BDS: Authorizations for Document Set
| | |
| | |-- ACTVT <FLD> Activity
| | | |
| | | |-----03
| | | ------30
| | |
| | |-- CLASSNAME <FLD> Business Document Service: Class name
| | | |
| | | |-----ALVLAYOUT*
| | | |-----DEVC_STXD_BITMAP
| | | ------REPORTWRITER
| | |
| | --- CLASSTYPE <FLD> Business Document Service: Class type
| | |
| | ------OT
| |
| |-- S_BTCH_JOB <OBJ> Background Processing: Operations on Background Jobs
| | |
| | --- T-D145001300 <AUT> Batch Processing: Operations on Batch Jobs
| | |
| | |-- JOBACTION <FLD> Job operations
| | | |
| | | |-----LIST
| | | |-----PROT
| | | |-----RELE
| | | ------SHOW
| | |
| | --- JOBGROUP <FLD> Summary of jobs for a group
| | |
| | ------*
| |
| |-- S_C_FUNCT <OBJ> C calls in ABAP programs
| | |
| | --- T-D145001300 <AUT> C calls in ABAP programs
| | |
| | |-- ACTVT <FLD> Activity
| | | |
| | | ------*
| | |
| | |-- CFUNCNAME <FLD> Name of a CALLable C routine
| | | |
| | | ------*
| | |
| | --- PROGRAM <FLD> Program Name with Search Help
| | |
| | ------*
Now i want an output in this manner:
100009,T-D1450013,S_BDS_DS,T-D145001300,ACTVT,03,FLD,Activity
100009,T-D1450013,S_BDS_DS,T-D145001300,ACTVT,30,FLD,Activity
100009,T-D1450013,S_BDS_DS,T-D145001300,CLASSNAME,ALVLAYOUT*,FLD,Business Document Service: Class name
100009,T-D1450013,S_BDS_DS,T-D145001300,CLASSNAME,DEVC_STXD_BITMAP,FLD,Business Document Service: Class name
100009,T-D1450013,S_BDS_DS,T-D145001300,CLASSNAME,REPORTWRITER,FLD,Business Document Service: Class name
100009,T-D1450013,S_BDS_DS,T-D145001300,CLASSTYPE,OT,FLD,Business Document Service: Class type
100009,T-D1450013,S_BTCH_JOB,T-D145001300,JOBACTION,LIST,FLD,Job operations
100009,T-D1450013,S_BTCH_JOB,T-D145001300,JOBACTION,PROT,FLD,Job operations
100009,T-D1450013,S_BTCH_JOB,T-D145001300,JOBACTION,RELE,FLD,Job operations
100009,T-D1450013,S_BTCH_JOB,T-D145001300,JOBACTION,SHOW,FLD,Job operations
100009,T-D1450013,S_BTCH_JOB,T-D145001300,JOBGROUP,*,FLD,Summary of jobs for a group
100009,T-D1450013,S_C_FUNCT,T-D145001300,ACTVT,*,FLD,Activity
100009,T-D1450013,S_C_FUNCT,T-D145001300,CFUNCNAME,*,FLD,Name of a CALLable C routine
100009,T-D1450013,S_C_FUNCT,T-D145001300,PROGRAM,*,FLD,Program Name with Search Help
Plz rescue me otherwise soon i will become an insomaniac.
Thnx in Advance
Quite frankly I'm not surprised that you're having sleepless nights, as I cannot see what rules you need to apply to get from format #1 to format #2. If you can formulate those, turning them into code ought to be straightforward enough.
However, I'm puzzled as to why you're posting it here. This looks like the sort of problem that is better suited to a perl data munger, something with good regular expressions and text manipulation.
By the way, is there any significance in the number of pipes and dashes (||| ---) or does that just mean that you don't know how to format ASCII text in these forums? If the latter you need to use the UBB tags [PRE] and [/PRE].
Cheers, APC
Similar Messages
-
Comparing 3 CSV Files and generating output to 4th One..
Hi,
I was trying to compare 3 different CSV files using the common field EmplID and generate output with the combination of all the CSV's. The fields in the CSV are below
CSV1 : EmplID,HName,Name,PreferredName,Location,Department
CSV2 : HName,EmplID,first_name,last_name,email
CSV3 : Emplid,Extension
I would like to generate the output CSV as below..
OutputCSV :EmplID,Hname,Name,PreferredName,Location,Department,first_name,last_name,email,Extension
The below script works but as it is comparing the data by row by row, it takes huge time to complete.. Can anybody suggest how can i improve the performance of the same...
$CSV1 = Import-CSV "Abc.CSV"
$CSV2 = Import-CSV "DEF.CSV"
$CSV3 = Import-CSV "GHI.CSV"
$Merged = ForEach($Record in $CSV1){
Add-Member -InputObject $Record -NotePropertyName 'first_name' -NotePropertyValue ($CSV2|Where{$_.EmplID -eq $Record.EmplID}|Select -Expand first_name)
Add-Member -InputObject $Record -NotePropertyName 'last_name' -NotePropertyValue ($CSV2|Where{$_.EmplID -eq $Record.EmplID}|Select -Expand last_name)
Add-Member -InputObject $Record -NotePropertyName 'email' -NotePropertyValue ($CSV2|Where{$_.EmplID -eq $Record.EmplID}|Select -Expand email)
Add-Member -InputObject $Record -NotePropertyName 'Extension' -NotePropertyValue ($CSV3|Where{$_.EmplID -eq $Record.EmplID}|Select -Expand Extension) -PassThru
$Merged | Export-CSV C:\Path\To\New.CSV -NoTypeInfoHi RP,
you can do this by creating a dictionary that uses the Employee ID as key. This allows you to iterate over each Csv only once and add values to the correct object each time. Didn't test it, but this ought to do the trick:
$CSV1 = Import-CSV "Abc.CSV"
$CSV2 = Import-CSV "DEF.CSV"
$CSV3 = Import-CSV "GHI.CSV"
$Hash = @{ }
foreach ($Record in $CSV1)
$Hash[$Record.EmplID] = $Record | Select EmplID, Hname, Name, PreferredName, Location, Department, first_name, last_name, email, Extension
foreach ($Record in $CSV2)
try
$Hash[$Record.EmplID].first_name = $Record.first_name
$Hash[$Record.EmplID].last_name = $Record.last_name
$Hash[$Record.EmplID].email = $Record.email
catch
Write-Warning "[Csv2]Failed to process $($Record.emplID): $($_.Exception.Message)"
foreach ($Record in $CSV3)
try
$Hash[$Record.EmplID].Extension = $Record.Extension
catch
Write-Warning "[Csv3]Failed to process $($Record.emplID): $($_.Exception.Message)"
$Hash.Values | Export-CSV C:\Path\To\New.CSV -NoTypeInfo
Cheers,
Fred
There's no place like 127.0.0.1 -
How to add CSV file extension in output format of sap document in SCOT
Hello All,
i have added CSV in conversion rule through “SAP Customizing Implementation Guide–> SAPNetWeaver –>SAP Web Application Server -> Basis Services -> Communication Interfaces -> SAPconnect Client-Wide Settings -> General Settings -> Conversion Rules”. but it is not showing in SCOT (o/p format for SAP document).
Please do needfuli found this string on net
add a Conversion-rule (transaction SCOT like this:
CSV CSV 1 SX_OBJECT_CONVERT_TXT_INT
How i Add . -
Output SELECT statement to CSV file
Can someone advise the best approach please
I'm trying to create a CSV file from the output of a SELECT statement in ApEx as a PL/SQL block. I initially thought the simplest approach would be to use SPOOL and then execute the SELECT startment but I think this is a SQLPlus command and can't be used in PL/SQL.
I then tried using the 'UTL_FILE.PUT' command which works for a single record but I'm not sure how to implement this where the SELECT returns multiple records.
DECLARE
fHandler UTL_FILE.FILE_TYPE;
v_DAT VARCHAR(20);
v_Handle VARCHAR2(20);
BEGIN
SELECT DATA INTO v_DAT FROM HIP_TEST;
v_Handle := CONCAT('HIP_',CONCAT(TO_CHAR(sysdate,'yyyymmddhhmi'),'.csv'));
fHandler := UTL_FILE.FOPEN('/nfsacademy/amp/live', v_Handle, 'w');
UTL_FILE.PUTF(fHandler, v_DAT);
UTL_FILE.FCLOSE(fHandler);
EXCEPTION
WHEN utl_file.invalid_path THEN
raise_application_error(-20000, 'Invalid path. Create directory or set UTL_FILE_DIR.');
END;Hi,
You can try this.
DECLARE
fHandler UTL_FILE.FILE_TYPE;
v_DAT VARCHAR(20);
v_Handle VARCHAR2(20);
BEGIN
v_Handle := CONCAT('HIP_',CONCAT(TO_CHAR(sysdate,'yyyymmddhhmi'),'.csv'));
fHandler := UTL_FILE.FOPEN('/nfsacademy/amp/live', v_Handle, 'w');
FOR I IN (SELECT DATA FROM HIP_TEST)
LOOP
UTL_FILE.PUTF(fHandler, i.data);
END LOOP;
UTL_FILE.FCLOSE(fHandler);
EXCEPTION
WHEN utl_file.invalid_path THEN
raise_application_error(-20000, 'Invalid path. Create directory or set UTL_FILE_DIR.');
END;** NOT TESTED **
Alternatively you can also use DBMS_OUTPUT.PUT_LINE.
Regards,
Avinash
Edited by: Avinash Tripathi on Nov 17, 2009 3:35 PM -
Report Total Wrapping/Missing Data in CSV FIle
PROBLEM:
We have an application were the totals in the report region will wrap when the total is negative and formatted with a negative sign preceding the number (e.g. -43,567.99). The wrapping results in users being confused to wether or not a value is negative or positive. We want all non-numeric columns to wrap so that the user does not have to scroll horizontally.
SOLUTIONS TRIED
1. Set the CCS Style attribute of a column to white-space:nowrap.
The value of CCS Style is inserted into span tags associated with a column value which in turn elliminates the wrapping in the detailed area of the report. However, I have no found a way to insert this type of span tag to the Total of a report region.
2. Modifying the format mask to present negative numbers in brackets (e.g. <43,567.99>).
This solves the wrapping issue . . . however results in a problem when outputting the report to a CSV file. When outputting to a CSV file the negative number that have been formatted using bracket are not included in the output. I believe that it interprets them as html tags <> and therefore eliminates them from the output.
3. Create duplicate amount columns in the report and apply a number format that places a negative sign in front of negative numbers and make this column display conditionally for CSV output only Then change the original column format mask to use brackets. Although this will work it seem a bit clunky, results in unnecessary pull of excess data and will require a lot of re-work/re-testing of our system.
REQUEST
Does anyone have any ideas on how I might either:
1. Add white-space:nowrap to the totals of the report region
2. Overcome the exclusion of negative numbers containing brackets from the CSV output.
3. HAve another approach to resolving this wrapping issue.
Thanks,
DavidAccording to this article http://www.cs.tut.fi/~jkorpela/html/nobr.html this is a known wrapping issue with Internet Explorer. Wrapping will occure when the following characters exists -()[]{}«»%°·\/!?. The author of the article suggest that the only way around this issue is too place -a or use white-space:nowrap in a [td] or [tr] tag.
This would suugest that I need to find a way to add html to the total column in the htmldb report . . . which I don't believe I can do . . . Does anyone know of a way to insert html into these total columns similiar to how we can be done using the CCS Style or HTML Expression attributes.
Thanks,
David. -
Add a carriage return in a .csv file
I running the following command which works but I would like to format the output in the CSV file. The "SecondaryAddresses" field is where my issue is. The field contains multiple addresses as such:
{[email protected], [email protected], [email protected]}
Current output in .csv file.
Desired output in .csv file.
I want to be able to add a return into the .csv file so the data is in one cell.
Get-Mailbox jblake -DomainController "DC01" -ResultSize Unlimited | Select-Object DisplayName,alias,PrimarySmtpAddress, @{Name=“SecondaryAddresses”;Expression={$_.EmailAddresses | Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object
{$_.SmtpAddress}}}
ChrisI think that is still not quite there, it is missing the filter on PrefixString.
Get-Mailbox jblake -DomainController "DC01" -ResultSize Unlimited | Select-Object DisplayName,alias,PrimarySmtpAddress, @{Name=“SecondaryAddresses”;Expression={($_.EmailAddresses | Where-Object {$_.PrefixString -ceq "smtp"}).SmtpAddress -join "`n"}}
Enclosing $_.EmailAddresses | Where-Object {$_.PrefixString -ceq "smtp"} in parenthesis lets us use the dot operator on the array that it returns. Accessing a property on an array that is actually a property on each of the objects in the array
should return an array of those property values (an array of SmtpAddresses), which we can then -join with the newline character. Note that this feature of arrays was added in v3.0 so in case you're on an older version this wouldn't work.
I also don't have the Exchange cmdlets, so I unfortunately I cannot test it either. -
Opening up csv file with Excel
There is a file that is comma separated values. When I open this file in Windows, I get Excel. When I open the same file in the Mac, I get a text file. How can I make it a default for csv files to open in Excel?
Select the file then press COMMAND-I to open the Get Info window. In the section titled "Open With" select Excel from the dropdown menu. If you want all CSV files to be opened by Excel, then click on the "Change All" button.
A better solution is to run Excel and import this particular file. Then save as a standard spreadsheet file. -
How to call a SP with dynamic columns and output results into a .csv file via SSIS
hi Folks, I have a challenging question here. I've created a SP called dbo.ResultsWithDynamicColumns and take one parameter of CONVERT(DATE,GETDATE()), the uniqueness of this SP is that the result does not have fixed columns as it's based on sales from previous
days. For example, Previous day, customers have purchased 20 products but today , 30 products have been purchased.
Right now, on SSMS, I am able to execute this SP when supplying a parameter. What I want to achieve here is to automate this process and send the result as a .csv file and SFTP to a server.
SFTP part is kinda easy as I can call WinSCP with proper script to handle it. How to export the result of a dynamic SP to a .CSV file?
I've tried
EXEC xp_cmdshell ' BCP " EXEC xxxx.[dbo].[ResultsWithDynamicColumns ] @dateFrom = ''2014-01-21''" queryout "c:\path\xxxx.dat" -T -c'
SSMS gives the following error as Error = [Microsoft][SQL Server Native Client 10.0]BCP host-files must contain at least one column
any ideas?
thanks
Hui
--Currently using Reporting Service 2000; Visual Studio .NET 2003; Visual Source Safe SSIS 2008 SSAS 2008, SVN --Hey Jakub, thanks and I did see the #temp table issue in our 2008R2. I finally figured it out in a different way... I manage to modify this dynamic SP to output results into
a physical table. This table will be dropped and recreated everytime when SP gets executed... After that, I used a SSIS pkg to output this table
to a file destination which is .csv.
The downside is that if this table structure ever gets changed, this SSIS pkg will fail or not fully reflecting the whole table. However, this won't happen often
and I can live with that at this moment.
Thanks
--Currently using Reporting Service 2000; Visual Studio .NET 2003; Visual Source Safe SSIS 2008 SSAS 2008, SVN -- -
Problem in getting .csv file as output
Hi All,
I am using ws_download function module to get .csv file as output . i am getting space between output values.But i want to get comma instead of space.
i am working on 4.6b version but in this version there no write filed separator field in gui_download function module.
Please suggest me the follow up
Regards
Sudhakar.use field-symbol and do sth like this
data str type string.
loop at itab.
do.
assign component sy-index of table itab to <F>.
concatenate str <f> ';' into str.
enddo.
endloop.
hope taht helps
Andreas -
Unable to output data to a csv file
hi,
i need to out put some values to a csv file (the one that is mapped to it in the databank). i have used the function
rswapp.setdatabankvalue "name", value
where name is the variable name that is mapped to the field that should be updated by the script and value contain a string value that i want to export...
somehow this code is not working properly.... :(
can someone help me.......
thanks in advanceHi Priyanshu,
The function setDatabankValue will not write to the .csv file, but it will override the current databank. This would be useful if you had a function in VBA that you would like to use to replace a Databanked parameter. In order to output to the csv you will need to use file i/o functions.
From online help the code below is the basic syntax where "newline" is what is going to be placed in test.txt
newline would be replaced by the new variable that you want to output. Also, be sure that you reference EmpirixUtilities in your VBA. Hope this helps.
Jim
Private Sub RSWVBAPage_beforePlay()
Dim m_util As EmpirixUtilities.FileIO
Set m_util = New EmpirixUtilities.FileIO
Dim resultb As Boolean
Dim mstatus As String
'write a line
resultb = m_util.WriteToFile("c:\Test.txt", "newlineText", Append, mstatus)
Call RSWApp.WriteToLog(CStr(resultb), "", mstatus)
Set m_util = Nothing
End Sub -
// Code Help need .. in Reading CSV file and display the Output.
Hi All,
I am a new Bee in code and started learning code, I have stared with Console application and need your advice and suggestion.
I want to write a code which read the input from the CSV file and display the output in console application combination of first name and lastname append with the name of the collage in village
The example of CSV file is
Firstname,LastName
Happy,Coding
Learn,C#
I want to display the output as
HappyCodingXYZCollage
LearnC#XYXCollage
The below is the code I have tried so far.
// .Reading a CSV
var reader = new StreamReader(File.OpenRead(@"D:\Users\RajaVill\Desktop\C#\input.csv"));
List<string> listA = new List<string>();
while (!reader.EndOfStream)
var line = reader.ReadLine();
string[] values = line.Split(',');
listA.Add(values[0]);
listA.Add(values[1]);
listA.Add(values[2]);
// listB.Add(values[1]);
foreach (string str in listA)
//StreamWriter writer = new StreamWriter(File.OpenWrite(@"D:\\suman.txt"));
Console.WriteLine("the value is {0}", str);
Console.ReadLine();
Kindly advice and let me know, How to read the column header of the CSV file. so I can apply my logic the display combination of firstname,lastname and name of the collage
Best Regards,
Raja Village Sync
Beginer CoderVery simple example:
var column1 = new List<string>();
var column2 = new List<string>();
using (var rd = new StreamReader("filename.csv"))
while (!rd.EndOfStream)
var splits = rd.ReadLine().Split(';');
column1.Add(splits[0]);
column2.Add(splits[1]);
// print column1
Console.WriteLine("Column 1:");
foreach (var element in column1)
Console.WriteLine(element);
// print column2
Console.WriteLine("Column 2:");
foreach (var element in column2)
Console.WriteLine(element);
Mark as answer or vote as helpful if you find it useful | Ammar Zaied [MCP] -
Output in a *.csv-File via text_io writes some lines twice
Hello
I wrote a report which returns the result in the previewer and in a *.csv-File. Now I have a problem with the datas in the *.csv-file: The first datarow on the second page (in the previewer) is in the *.csv-file listed twice.
The putfile-statement is in the format-trigger at the repeating-frame. I think the trigger is executed in the first page before the page break. Then the report notice that there is no more place. The page break will be done and after that the trigger is executed again.
How can I get a right listing? Could anybody help me?
Thanks
Ingehello,
you might want to check out the enhancement introduced with the latest patch. we have introduced a new output format DELIMITEDDATA that allows you to create "real" csv output (header on top, regular data, ...)
regards,
philipp -
Help with output to 2 CSV files
I created a script to parse through AD and output a list of computers that have certain info in the description field and it is working (wouldn't mind some critique if things could be done a better/faster way). Now, what I am trying to do is split
the output into 2 CSV files based on what is in the $descwho variable. But I am not sure where to start (not looking for someone to rewrite the script but point me in the right direction). I have tried a couple things but so far I have not gotten
anywhere.
Function Get-ScriptDirectory {
if($hostinvocation -ne $null) {
Split-Path $hostinvocation.MyCommand.path
} else {
Split-Path $script:MyInvocation.MyCommand.Path
#Variable that provides the location of the script
[string]$ScriptDirectory = Get-ScriptDirectory
Function Clean-OU {
#clean OU removes FQDN/RootOU from the start and $computername from the end of the OU string
Param (
$OriginalOU,
$computer
$ouArray = $OriginalOU.split("/")
$newOU = $null
Foreach ($OU in $ouArray) {
If (($ou -ne "FQDN") -and ($ou -ne "RootOU") -and ($ou -ne $computer)){
If (!$newOu) {
$newOU = ".../$ou"
} Else {
$newOU += "/$ou"
return $newOU
$path = "$ScriptDirectory\ad_report_2.csv" #path to where report is saved
Get-ADComputer -Filter * -Properties Description,Enabled,MemberOf,CanonicalName | % {
$computer = $_.Name #name of computer
$desc = $_.Description #description field associated with computer
$DistinguishedName = Clean-OU -OriginalOU $_.CanonicalName -Computer $computer #FQDN/RootOU/PROD/WIN7/64bit/LT/PF-123456
# is PC in the SpecialGroup security group?
If ($_.memberof -match "SpecialGroup"){[string]$memberOf = "SpecialGroup"}else{$memberOf = "N/A"}
If ($desc){#if Desc = true
If (($desc.StartsWith("AEHT")) -or ($desc.StartsWith("VF-")) -or ($desc.StartsWith("Disabeled:"))) {
$descArr = $desc.Split(":").Trim()
$descWho = $descArr[0]
$description = $descArr[1]
$dwTemp = $descArr[2]
If ($dwTemp -match "\[IT Support\]"){$dwPrefix = "IT Support"}
elseif($dwTemp -match "\[App Dev\]"){$dwPrefix = "App Dev"}
elseIf($dwTemp -match "\[Business\]"){$dwPrefix = "Business"}
$dwTemp = $dwTemp -replace "\[IT Support\]" -replace "\[App Dev\]" -replace"\[Business\]"
$descWhen = "$dwPrefix - $dwTemp"
Write-Host $Computer -NoNewline
#Write-Host - $memberOf -NoNewline
#Write-Host - $enabled -NoNewline
Write-Host - $descWho -NoNewline
Write-Host - $description -NoNewline
Write-Host - $descWhen -NoNewline
Write-Host
$Record = @{"Computer" = $Computer}
$record.add("DescByWho",$descWho)
$record.add("Description",$description)
$record.add("DescWhen",$descWhen)
$record.add("OU",$DistinguishedName)
$record.add("MemberOf",$memberof)
New-Object PSObject -Property $record |Sort-Object -Property DescByWho | Select Computer, DescByWho, Description, DescWhen, MemberOf, OU
} | export-csv -path $path -NoTypeInformationHi Mike,
If you want to divide the output to two csv files based on the variable $descWho, please refer to this script, please also note I havn't tested:
#modify
$path1 = "$ScriptDirectory\ad_report_1.csv" #path to where report is saved
$path2 = "$ScriptDirectory\ad_report_2.csv" #path to where report is saved
$output1=@()
$output2=@()
#modify
Get-ADComputer -Filter * -Properties Description,Enabled,MemberOf,CanonicalName | % {
$computer = $_.Name #name of computer
$desc = $_.Description #description field associated with computer
$DistinguishedName = Clean-OU -OriginalOU $_.CanonicalName -Computer $computer #FQDN/RootOU/PROD/WIN7/64bit/LT/PF-123456
# is PC in the SpecialGroup security group?
If ($_.memberof -match "SpecialGroup"){[string]$memberOf = "SpecialGroup"}else{$memberOf = "N/A"}
If ($desc){#if Desc = true
If (($desc.StartsWith("AEHT")) -or ($desc.StartsWith("VF-")) -or ($desc.StartsWith("Disabeled:"))) {
$descArr = $desc.Split(":").Trim()
$descWho = $descArr[0]
$description = $descArr[1]
$dwTemp = $descArr[2]
If ($dwTemp -match "\[IT Support\]"){$dwPrefix = "IT Support"}
elseif($dwTemp -match "\[App Dev\]"){$dwPrefix = "App Dev"}
elseIf($dwTemp -match "\[Business\]"){$dwPrefix = "Business"}
$dwTemp = $dwTemp -replace "\[IT Support\]" -replace "\[App Dev\]" -replace"\[Business\]"
$descWhen = "$dwPrefix - $dwTemp"
Write-Host $Computer -NoNewline
#Write-Host - $memberOf -NoNewline
#Write-Host - $enabled -NoNewline
Write-Host - $descWho -NoNewline
Write-Host - $description -NoNewline
Write-Host - $descWhen -NoNewline
Write-Host
$Record = @{"Computer" = $Computer}
$record.add("DescByWho",$descWho)
$record.add("Description",$description)
$record.add("DescWhen",$descWhen)
$record.add("OU",$DistinguishedName)
$record.add("MemberOf",$memberof)
#modify
New-Object PSObject -Property $record
if($descWho -like "a*"){ #use if statement to filter the $descwho begin with "a" character
$output1+=New-Object PSObject -Property $record}
else{
$output2+=New-Object PSObject -Property $record}
$output1|Sort-Object -Property DescByWho | Select Computer, DescByWho, Description, DescWhen, MemberOf, OU|export-csv -path $path1 -NoTypeInformation
$output2|Sort-Object -Property DescByWho | Select Computer, DescByWho, Description, DescWhen, MemberOf, OU|export-csv -path $path2 -NoTypeInformation
Best Regards,
Anna Wang -
Spool output to .csv file - having issues with data display
Hi,
Need to deliver the output of a select query which has around 80000 records to a .csv file. A procedure is written for the select query and the procedure is being called in the spool script. But few of the columns have comma(,) in the values. For Example, there is a personal_name column in the select query which says the name as " James, Ed". Then output is displayed in different columns. Hence the data is being shifted to the right for the remaining columns.
Could some one help fix this issue. I mainly used a procedure as the select query is about three pages and hence want the script to look clear.
Script is,
set AUTOPRINT ON ;
set heading ON;
set TRIMSPOOL ON ;
set colsep ',' ;
set linesize 1000 ;
set PAGESIZE 80000 ;
variable main_cursor refcursor;
set escape /
spool C:\documents\querys\personal_info.csv
EXEC proc_personal_info(:main_cursor);
spool off;Hi,
set PAGESIZE 80000 ;is not valid and it will print header as default every 14 rows.
You can avoid printing the header in this way:
set AUTOPRINT ON ;
set heading ON;
set TRIMSPOOL ON ;
set colsep ',' ;
set linesize 1000 ;
set PAGESIZE 0 ;
set escape /
set feedback off
spool c:\temp\empspool.csv
SELECT '"'||ename||'"', '"'||job||'"'
FROM emp;
spool offThe output will look like this in this case
"SMITH" ,"CLERK"
"ALLEN" ,"SALESMAN"
"WARD" ,"SALESMAN"
"JONES" ,"MANAGER"
"MARTIN" ,"SALESMAN"
"BLAKE" ,"MANAGER"
"CLARK" ,"MANAGER"
"SCOTT" ,"ANALYST"
"KING" ,"PRESIDENT"
"TURNER" ,"SALESMAN"
"ADAMS" ,"CLERK"
"JAMES" ,"CLERK"
"FORD" ,"ANALYST"
"MILLER" ,"CLERK"You can also consider creating a unique column by concatenating the columns in this way:
spool c:\temp\empspool.csv
SELECT '"'||ename||'","'||job||'"' In this case the output will look without spaces between columns:
"SMITH","CLERK"
"ALLEN","SALESMAN"
"WARD","SALESMAN"
"JONES","MANAGER"
"MARTIN","SALESMAN"
"BLAKE","MANAGER"
"CLARK","MANAGER"
"SCOTT","ANALYST"
"KING","PRESIDENT"
"TURNER","SALESMAN"
"ADAMS","CLERK"
"JAMES","CLERK"
"FORD","ANALYST"
"MILLER","CLERK"Regards.
Al
Edited by: Alberto Faenza on May 2, 2013 5:48 PM -
Issue in conversion of output file from alv to csv file using GUI_DOWNLOAD
hi,
I am using GUI_DOWNLOAD to convert the internal table that am getting as the output of an alv into a csv(comma separated file) file.I am using the following code but its not generating a csv file instead it is generating a normal space delimited file.
The code is as follows:
data : lv_fname type string.
lv_fname = 'C:\Users\pratyusha_tripathi\Desktop\status8.csv'. " Provide the file path & file name with CSV extention
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_fname " File name including path, give CSV as extention of the file
FILETYPE = 'DAT'
WRITE_FIELD_SEPARATOR = '#' " Provide comma as separator
tables
data_tab = ITAB " Pass the Output internal table
FIELDNAMES =
EXCEPTIONS
OTHERS = 22
IF sy-subrc 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Kindly let me know what changes can be made to make my code work.Also can GUI_download be used for batch processing and storing the output in application server?
Thanks ,
PratyushaHi,
the short text description for WRITE_FIELD_SEPARATOR is "Separate Columns by Tabs in Case of ASCII Download", so why do you expect a comma?
Try SAP_CONVERT_TO_CSV_FORMAT and then download.
And no, GUI_DOWNLOAD is only for download via SAP GUI to a users computer.
Best regards,
Oliver
Maybe you are looking for
-
Qtn: I have 10 standard elementary search helps in collective standard search help, how to deactivate the 10th elementary search help?
-
Windows Internet Explorer 9 will not allow me to download Firefox. How can I fix this?
Running Windows Vista with Internet explorer 9. Need to download Mozilla Firefox. I get to the Firefox download page, click on the Download button. I get at message asking if I would like to save the Firefox Setup Stub, which I did. A small extra win
-
Mail Crashes after installing Safari 3 Beta and
Last night (technically early this morning) I installed these three things at the same time: Safari 3 Beta Security Update 2007-006 (Universal) Mac OS X Update (Intel) Once I restarted my Mail.app would not launch. It bounces a single time and that i
-
Boot Camp Upgrade Utility for XP to Windows 7
I want to upgrade from XP running under Boot Camp to Windows 7. During the installation I get a "0x80070005" error code. Following advice from Apple support I downloaded the Upgrade Installation Utility, but it was written for Vista and will not run
-
Application Outline Update Kills Performance
Developing small application on a machine with several gigs of hertz and memory. Keyboard becomes non-responsive with the Application Outline window open: about a half second delay between characters typed in. Work around is close the Application Out