Manipulate CSV File Data
Hello,
Our Active Directory structure only lists the person's manager in the format of an email address. After running a Get-ADUser command and exporting its data to a csv file. I want to import the csv file which will be in the format shown below, then manipulate
it, so the manager1 field is converted to the relevant objectGUID and populated in the Manager_objectGUID field.
I'm completely new to PowerShell so any assistance would be much appreciated.
Thanks
Stuart
$OldCSV = "C:\OldADUsers.csv"
$NewCSV = "C:\NewADUsers.csv"
Add-Content $OldCSV "objectGUID,mail,givenName,sn,manager1,Manager_objectGUID"
Add-Content $OldCSV "7c1be78f,[email protected],Mickey,Mouse,,"
Add-Content $OldCSV "982874ab,[email protected],Donald,Duck,[email protected],"
$ADUsers = Import-CSV $OldCSV
# collect managers
$Managers = @{}
ForEach ($ADUser in $ADUsers)
$Managers.Add($ADUser.Mail,$ADUser.ObjectGUID)
# Get Managers
ForEach ($ADUser in $ADUsers)
IF ($ADUser.manager1 -NE "")
If ($Managers[$ADUser.manager1] -NE $Null)
$ADUser.Manager_objectGUID = $Managers[$ADUser.manager1]
$ADUsers | Export-CSV $NewCSV
Get-Content $NewCSV
Gives this output
#TYPE System.Management.Automation.PSCustomObject
"objectGUID","mail","givenName","sn","manager1","Manager_objectGUID"
"7c1be78f","[email protected]","Mickey","Mouse","",""
"982874ab","[email protected]","Donald","Duck","[email protected]","7c1be78f"
Similar Messages
-
Related to CSV file data upload
Hi all,
I am new to the oracle technology.
While uploading the data from csv file i got this error
"SQL*Loader-350: Syntax error at line 4.
Expecting keyword TABLE, found "xxgfs_gen_text_lookups".
APPEND INTO xxgfs_gen_text_lookups"
my csv file data is
Invoice Match Options,,,Invoice,,
Invoice Match Options,,,Receipt,,
Invoice Match Options,,,Purchase Order,,X
Invoice Type,A 00,Advance,Standard,Standard invoice,
Invoice Type,B 00,Expense,Standard,Standard invoice,
Invoice Type,2 00,Debit Memo,Credit Memo,Credit Memo,
Invoice Type,2 20,EDI Debit Memo,Credit Memo,Credit Memo,
Invoice Type,1 00,Invoice,Standard,Standard invoice,
Invoice Type,1 01,Arrow Credit,Standard,Standard invoice,,
Invoice Type,1 10,Recurring Payments,Standard,Standard invoice,,
Invoice Type,1 20,EDI Invoices,Standard,Standard invoice,,
Invoice Type,1 21,Imaged Invoice,Standard,Standard invoice,X,Default when entering from form
Invoice Tax Code,XMT,DO NOT USE,,,,
Invoice Tax Code,STE,DO NOT USE,,,,
Invoice Tax Code,,,,,,
Invoice Tax Code,,,,,,
Invoice Tax Code,,,,,,
Invoice Tax Code,,,,,,
Invoice Tax Code,,,,,,
Invoice Tax Code,,,,,,
Invoice Tax Code,,,,,,
Invoice Tax Code,,,,,,
Invoice Tax Code
If i am removing the blank row then also it is giving the same problem.
If anybody face the same problem then please help me out.
thanks in advance to u all for ur help.
-RajnishThis is the Oracle Application Express (formerly known as HTML DB) forum. SQL*Loader related questions should be asked in the Database SQL forum (PL/SQL or Database General Forum (General Database Discussions but being a nice guy familiar with SQL*Loader I will "give it a go".
The error message you are getting indicates that you have a syntax error in your control file. The syntax for the APPEND keyword is APPEND INTO TABLE table_name. So change "APPEND INTO xxgfs_gen_text_lookups" to "APPEND INTO TABLE xxgfs_gen_text_lookups".
Mike -
Load .csv file data with OWb Process flow using Web
Hi,
I Have a file in my local machine( Machines on multiple user's), need to load data through Web user interface.
Let's say have a web page with multiple radio buttons respective to different sources, by clicking on each button will pass the path of .csv file to through Application, (API or Java programming interface) execute owb Process flow as a accepting file path as a input parameter to execute for loading purpose.
Should facilitate view data, Update data through web based on user requests.
Need your guidence how can i implement this with OWb 11g R2.
Assuming with Web browser functionality. Please confirm it and if yes, please throw some light how could be the steps to implement.
ThanksHi David,
Thanks for your reply.
Undersatnd your proposed solution.But my requirement should be as follows.
1. Currently under consideration using web page likely to be implement with Java, allowing users to load .csv file data into staging area.(Loading flat file into Data abse table)
Case 1, Assuming OWB software is not installed on user machine. I think no.
Is it possible through web page (this case Java page) to trigger java procedure/Pl/SQl procedure or integration of both to laod data into staging area.If yes, how it could effect performance of data load with 1 GB file.
Case 2, OWb client software installed on User machine, while runtime passing parameters means passing manually?
In case it is automated, how should i pass machine name & Path to owb runtime web browser.
Could you please show me guidence how should I acheive this functionality with APEX customization part?
Thanks agin for your support.
Anil -
Hi all,
I am new to the oracle technology.
While uploading the data from csv file i got this error
"SQL*Loader-350: Syntax error at line 4.
Expecting keyword TABLE, found "xxgfs_gen_text_lookups".
APPEND INTO xxgfs_gen_text_lookups"
my csv file data is
Invoice Match Options,,,Invoice,,
Invoice Match Options,,,Receipt,,
Invoice Match Options,,,Purchase Order,,X
Invoice Type,A 00,Advance,Standard,Standard invoice,
Invoice Type,B 00,Expense,Standard,Standard invoice,
Invoice Type,2 00,Debit Memo,Credit Memo,Credit Memo,
Invoice Type,2 20,EDI Debit Memo,Credit Memo,Credit Memo,
Invoice Type,1 00,Invoice,Standard,Standard invoice,
Invoice Type,1 01,Arrow Credit,Standard,Standard invoice,,
Invoice Type,1 10,Recurring Payments,Standard,Standard invoice,,
Invoice Type,1 20,EDI Invoices,Standard,Standard invoice,,
Invoice Type,1 21,Imaged Invoice,Standard,Standard invoice,X,Default when entering from form
Invoice Tax Code,XMT,DO NOT USE,,,,
Invoice Tax Code,STE,DO NOT USE,,,,
Invoice Tax Code,,,,,,
Invoice Tax Code,,,,,,
Invoice Tax Code,,,,,,
Invoice Tax Code,,,,,,
Invoice Tax Code,,,,,,
Invoice Tax Code,,,,,,
Invoice Tax Code,,,,,,
Invoice Tax Code,,,,,,
Invoice Tax Code
If i am removing the blank row then also it is giving the same problem.
If anybody face the same problem then please help me out.
thanks in advance to u all for ur help.
-RajnishRunning SQL*Loader as:
sqlload userid=... control=... data=... log=...
HOSTSTR logical has been set to same value as your connection string but
without domain name.
When you have specified connect string (ie. SCOTT/TIGER@DATABASE) but no
domain you receive these errors:
SQL*Loader-704: Internal error: ulconnect: OCIServerAttach [0]
ORA-12154: TNS:could not resolve service name
When you have not specified connect string (ie. SCOTT/TIGER) you receive
these errors:
SQL*Loader-704: Internal error: ulconnect: OCIServerAttach [0]
ORA-12162: TNS:service name is incorrectly specified
Your sqlnet.ora has:
names.default_domain entry = world
The syntax in your tnsnames.ora entry is correct.
Your entry in tnsnames.ora does not include the .WORLD extension (default
domain from sqlnet.ora).
Solution Description
Specify the .WORLD in your tnsnames.ora and also in your connect string.
This will remove the error.
Also, ensure you are not hitting Bug 893290. Can you connect to the database from that server using sqlplus? -
Hi All,
I have a CSV file having data in cell. I have to load the csv file data in supporting table.
In code, I will pass parameters as - csv file name, path and supporting table name that required inserting the file data. (This is just a sample code; I required handling many things)
My Sample CSV file data: (Data are comma separated) ,In file in third,have null value ,Plese help to handle null values in below code while inserting.
1,AB,1/1/2013
2,CD,1/1/2012
3,<null>,1/1/2013Sample Code:
DECLARE
v_csvfile VARCHAR2(30) := 'temp.csv';--<<This is the csv file name>>
v_csvpath VARCHAR2(30) := --<<This is the path>>
v_csvtab VARCHAR2(30) := 'TEMP';
v_csvdata VARCHAR2(32767);
v_csveof BOOLEAN := FALSE;
v_csvfilehandle utl_file.file_type;
v_str VARCHAR2(32767);
BEGIN
v_csvfilehandle := utl_file.fopen(v_csvpath, v_csvfile, 'r', 32767);
WHILE NOT v_csveof
LOOP
BEGIN
utl_file.get_line(v_csvfilehandle, v_csvdata);
FOR i IN (SELECT s.data_type, s.internal_column_id
FROM user_tab_cols s
WHERE s.table_name = UPPER(v_csvtab)
ORDER BY internal_column_id)
LOOP
IF i.data_type = 'DATE'
THEN
v_str := v_str || 'TO_DATE (' || ' REGEXP_SUBSTR( ' || '''' ||
v_csvdata ||
'''' || ' ,' || '''' || '[^,]+' || '''' ||
' ,1,' || i.internal_column_id || ' ),' || '''' ||
'MM/DD/YYYY' || '''' || ' )';
ELSE
v_str := v_str || ' REGEXP_SUBSTR( ' || '''' ||
v_csvdata ||
'''' || ' ,' || '''' || '[^,]+' || '''' ||
' ,1,' || i.internal_column_id || ' ),';
END IF;
END LOOP;
--DBMS_OUTPUT.put_line('INSERT INTO ' || v_csvtab || ' VALUES ( ' || v_str || ' )');
EXECUTE IMMEDIATE 'INSERT INTO ' || v_csvtab || ' VALUES ( ' || v_str || ' )';
v_str := NULL;
EXCEPTION
WHEN no_data_found THEN
v_csveof := TRUE;
END;
END LOOP;
utl_file.fclose(v_csvfilehandle);
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(dbms_utility.format_error_backtrace ||
' Err ' || SQLERRM);
RAISE;
END;Script to create sample supporting table:
CREATE TABLE TEMP
(col1 VARCHAR2(100),
col2 VARCHAR2(100),
col3 DATE );Thanks,Don't re-invent the wheel.
If your CSV is on the database server (it must be if you are using UTL_FILE), use an external table
http://docs.oracle.com/cd/E11882_01/server.112/e22490/et_concepts.htm#SUTIL011
If your CSV is on a client PC, use Sql*Loader
http://docs.oracle.com/cd/E11882_01/server.112/e22490/ldr_concepts.htm#SUTIL003 -
Hi everyone,
I am trying to create a csv file.
One field that I am trying to out put is the description and has commas, that is throwing my columns out of sync.
I have tries putting the charactor ' around the data but all it does is output that charactor in the data.
my code is this
public File createFile(Vector downloadObject){
Iterator iterator = downloadObject.iterator();
String query ="";
try {
Format formatter2 = new SimpleDateFormat("ddMMyyyy");
String fileName="DELIVERY" + ".csv";
File file = new File(fileName);
StringBuffer output = new StringBuffer();
while (iterator.hasNext()){
VODownloadObject downloadObject2 = (VODownloadObject)iterator.next();
query =
"'" +
downloadObject2.getStrokeNumber().trim()
+ "','"+ downloadObject2.getJdeIdNumber()
+ "','"+ downloadObject2.getRollNumber()
+ "','"+ downloadObject2.getSupplier()
+ "',"+ ",'"+ downloadObject2.getQuality()
+ "','"+ downloadObject2.getColour()
+ "','"+ downloadObject2.getSupplierRollNumber()
+ "',"+ ",'"+ downloadObject2.getDeliveryDate()
+ "','"+ downloadObject2.getFabricComposition()
+ "',"+ ","+ ",'"+ downloadObject2.getTicketLength()
+ "','"+ downloadObject2.getTicketWidth()
+ "',"+ ","+ ","+ ",";
output.append(query + "\r\n");
BufferedWriter out = new BufferedWriter(new FileWriter(fileName));
out.write(output.toString());
out.close();
return file;
} catch (IOException e) {
e.printStackTrace();
return null;
}the output is this.
'PA?????T','2/664659 ','153920','Menswear Formal, Shirts ',,'null','null',' ',,'11/07/2006','null',,,'-330000',' ',
in the "'Menswear Formal, Shirts " field, this is one field but it is splitting up into 2 fields because there is a comma after Formal. Anyone know how I can keep this as one field but with a comma in it?
thanks in advanceI have abandoned my last appoach altogether
I am using com.Ostermiller.util.CSVPrinter
here is my final working class
public File createFile(Vector downloadObject){
Iterator iterator = downloadObject.iterator();
String query ="";
try {
Format formatter2 = new SimpleDateFormat("ddMMyyyy");
String fileName="DELIVERY" + ".csv";
File file = new File(fileName);
BufferedWriter out = new BufferedWriter(new FileWriter(fileName));
ExcelCSVPrinter ecsvp = new ExcelCSVPrinter(
out
while (iterator.hasNext()){
VODownloadObject downloadObject2 = (VODownloadObject)iterator.next();
String quality = " ";
if (downloadObject2.getQuality()!=null){
quality = downloadObject2.getQuality().trim();
String colour = " ";
if (downloadObject2.getColour()!=null){
colour = downloadObject2.getColour().trim();
String fabricComposition = " ";
if (downloadObject2.getFabricComposition()!=null){
fabricComposition =downloadObject2.getFabricComposition().trim();
ecsvp.writeln(new String [] {
downloadObject2.getStrokeNumber().trim(),downloadObject2.getJdeIdNumber().trim(),
downloadObject2.getRollNumber(), downloadObject2.getSupplier().trim(), " " ,
quality , colour , downloadObject2.getSupplierRollNumber().trim() , " ",
downloadObject2.getDeliveryDate().trim(), fabricComposition , " ", " ",
downloadObject2.getTicketLength(), downloadObject2.getTicketWidth().trim(),
out.close();
return file;
} catch (IOException e) {
e.printStackTrace();
return null;
} -
Upload csv file data to sql server tables
Hi all,
I want clients to upload csv file from their machines to the server.
Then the program should read all the data from the csv file and do a bulk insert into the SQL Server tables.
Please help me of how to go about doing this.
Thanx in advance.....1) Use a multipart form with input type="file" to let the client choose a file.
2) Get the binary stream and put it in a BufferedReader.
3) Read each line and map it to a DTO and add each DTO to a list.
4) Persist the list of DTO's.
Helpful links:
1) http://www.google.com/search?q=jsp+upload+file
2) http://www.google.com/search?q=java+io+tutorial
3) http://www.google.com/search?q=java+bufferedreader+readline
4) http://www.google.com/search?q=jdbc+tutorial and http://www.google.com/search?q=sql+tutorial -
Hi,
Data load from Flat File.
The master data is loaded using CSV file.
Emp ID; in source file it is replesented as 1,2,3..10...1009
But when i load the data it is being converted to 0000000001,0000000002....etc
The info object Data Type is Char and Length is 10 and Conversion Routine is none
I want it to be loaded as 1,2,3... as it is as it is in source file
ThanksHi,
Right click on that cell -> Format cells - > Number (tab) -> select Text and click OK.
Hope this helps.
PB -
Comparing SQL Data Results with CSV file contents
I have the following scenario that I need to resolve and I'm unsure of how to approach it. Let me explain what I am needing and what I have currently done.
I've created an application that automatically marks assessments that delegates complete by comparing SQL Data to CSV file data. I'm using C# to build the objects required that will load the data from SQL into a dataset which is then compared to the
associated CSV file that contains the required results to mark against.
Currently everything is working as expected but I've noticed that if there is a difference in the number of rows returned into the SQL-based dataset, then my application doesn't mark the items at all.
Here is an example:
ScenarioCSV contains 4 rows with 8 columns of information, however, let's say that the delegate was only able to insert 2 rows of data into the dataset. When this happens it marks everything wrong because row 1 in both CSV and dataset files were correct,
however, row 2 in the dataset holds the results found in row 4 in the CSV file and because of this it is comparing it against row 2 in the CSV file.
How can I check whether a row, regardless of its order, can be marked as it does exist but not in the same order, so I don't want the delegate to lose marks just because the row data in the dataset is not perfectly in the same order of the row data
in the CSV file???
I'm at a loss and any assistance will be of huge help to me. I have implemented a ORDER BY clause in the dataset and ensured that the same order is set in the CSV file. This has helped me for scenarios where there are the right number of rows in the dataset,
but as soon as there is 1 row that is missing in the dataset, then the marking just doesn't allow for any marks for both rows even if the data is correct.
I hope I've made sense!! If not, let me know and I will provide a better description and perhaps examples of the dataset data and the csv data that is being compared.
Thanks in advance....I would read the CSV into a datatable using oledb. Below is code I wrote a few weeks ago to do this.
Then you can compare two datatables by a common primary key (like ID number)
Below is the webpage to compare two datatables
http://stackoverflow.com/questions/10984453/compare-two-datatables-for-differences-in-c
You can find lots of examples by perform following google search
"c# linq compare two dattatable"
//Creates a CSVReader Class
public class CSVReader
public DataSet ReadCSVFile(string fullPath, bool headerRow)
string path = fullPath.Substring(0, fullPath.LastIndexOf("\\") + 1);
string filename = fullPath.Substring(fullPath.LastIndexOf("\\") + 1);
DataSet ds = new DataSet();
try
if (File.Exists(fullPath))
string ConStr = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}" + ";Extended Properties=\"Text;HDR={1};FMT=Delimited\\\"", path, headerRow ? "Yes" : "No");
string SQL = string.Format("SELECT * FROM {0}", filename);
OleDbDataAdapter adapter = new OleDbDataAdapter(SQL, ConStr);
adapter.Fill(ds, "TextFile");
ds.Tables[0].TableName = "Table1";
foreach (DataColumn col in ds.Tables["Table1"].Columns)
col.ColumnName = col.ColumnName.Replace(" ", "_");
catch (Exception ex)
MessageBox.Show(ex.Message);
return ds;
jdweng -
Hi,
I am running Data-Driven test on different machines with different input values in .CSV file in batch mode.we are facing following problem:
Test not considering modified values in .CSV file until we recompile the test.
Is there any way to avoid this dependency of compilation after updating .CSV file???
Regards,
Nagasree.Assuming the CSV is part of the Visual Studio solution. Open the properties panel for the CSV file from solution explorer. Set "Copy to output directory" to "Copy if newer" or to "Copy always". Some documents recommend
"Copy if newer" but I prefer "Copy always" as occasionally a file was not copied as I expected. The difference between the two copy methods is a little disk space and a little time, but disks are normally big and the time to copy is normally
small. Any savings are, in my opinion, far outweighed by being sure that the file will be copied correctly.
See also
http://stackoverflow.com/questions/23469100/how-to-run-a-test-many-times-with-data-read-from-csv-file-data-driving/25742114#25742114
Regards
Adrian -
Hi, so I have a CSV file in my working directory and dont know how to load in into a graph in VB. I already loaded my chart into the form and its called "Chart1" with "Series1".
The CSV has the following structure:
Date Value1 Value2
27/04/2012 45.1 60.1
26/04/2012 45.2 60.2.. ..
I cant figure out how to extract this data from the "*.csv" file and put in it a graph where the
Date is the x axis and the
Value2 is the y axis.
Any code would be greatly appreciated!Is the CSV file data in reverse date order? Your example includes only two lines, so the sequence is not clear.
If so, then you want to add the items to the series by working from the end of the file towards the beginning of the file. That would plot the points along the x-axis in order of increasing date. Is that correct?
But then you say that you want to plot from the beginning to a certain date. Do you mean that you want to plot (reversed) from the beginning of the file to a certain nominated ending date? Or do you want to plot the items starting at the end of the file
and working backwards through the file so that the plot starts at a nominated starting date? I have assumed the former.
To adjust the above code for these new requirements you should load the data into an object that you can manipulate to your requirements. Then you need to separate the plotting from the file access. A list is more suitable than an array.
Dim Readings As List(Of Reading) = New List(Of Reading)
Dim StartDate As Date = New Date(2012, 4, 24)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim CurrentPoint As Integer = 0
Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser("C:\Users\Public\Readings.txt")
MyReader.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited
MyReader.Delimiters = New String() {","}
Dim currentRow As String()
While Not MyReader.EndOfData
Try
currentRow = MyReader.ReadFields()
Dim D As String = currentRow(0)
Try
Dim Y As Double = CDbl(currentRow(2))
Readings.Add(New Reading(D, Y))
Catch ex As InvalidCastException
If CurrentPoint <> 0 Then
MsgBox("Item " & currentRow(2) & " is invalid. Skipping")
End If
End Try
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
If CurrentPoint <> 0 Then
MsgBox("Line " & ex.Message & " is invalid. Skipping")
End If
End Try
End While
End Using
Readings.Reverse()
CurrentPoint = 0
Chart1.Series(0).Points.Clear()
For Each R As Reading In Readings
Dim D As Date = CDate(R.Read_Date)
If D >= StartDate Then
Chart1.Series(0).Points.AddY(R.Read_Data)
Chart1.Series(0).Points(CurrentPoint).AxisLabel = R.Read_Date
CurrentPoint += 1
End If
Next
End Sub
That code uses the following class:
Public Class Reading
Public Read_Date As String
Public Read_data As Double
Public Sub New(ByVal Item1 As String, ByVal item2 As Double)
Read_Date = Item1
Read_data = item2
End Sub
End Class
I know this thread is a couple years old but I tried this code and it works in Studio 2013 Community and it is very close to what I need. I want to make it a line chart and I want to have 4 series- Temp, Temp_SP, RH% and RH%_SP so I can log some trending
data from an environmental chamber at work. Can someone help me out with this?
Thanks,
Dan -
Getting Issue while uploading CSV file into internal table
Hi,
CSV file Data format as below
a b c d e f
2.01E14 29-Sep-08 13:44:19 2.01E14 SELL T+1
actual values of column A is 201000000000000
and columen D is 201000000035690
I am uploading above said CSV file into internal table using
the below coding:
TYPES: BEGIN OF TY_INTERN.
INCLUDE STRUCTURE KCDE_CELLS.
TYPES: END OF TY_INTERN.
CALL FUNCTION 'KCD_CSV_FILE_TO_INTERN_CONVERT'
EXPORTING
I_FILENAME = P_FILE
I_SEPARATOR = ','
TABLES
E_INTERN = T_INTERN
EXCEPTIONS
UPLOAD_CSV = 1
UPLOAD_FILETYPE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
am getting all columns data into internal table,
getting problem is columan A & D. am getting values into internal table for both; 2.01E+14. How to get actual values without modifying the csv file format.
waiting for your reply...
thanks & regards,
abhiHi Saurabh,
Thanks for your reply.
even i can't double click on those columns.
b'se the program needs be executed in background there can lot of csv file in one folder. No manual interaction on those csv files.
regards,
abhi -
How to load csv file in oracle table
Hi,
i have csv files to which i want to load the csv file data and table structure in oracle. my csv files on the window machine but database is runing on ibm aix.so how to do it please any one can help me about. thanks a lot in advance
i know th syntax below
$sqlldr userid=username/password control=<filename> log=<log filename>Hello,
Yes, with SQL*Loader you can do it.
But first you have to create a Table into your database with columns and datatype matching
the content of you "csv" file.
Then, you'll have to prepare a control file and use the option fields terminated by "," as it's
a "csv" format.
Then, you could execute your statement.
Please, find enclosed a link with some example about SQL*Loader and "csv" file:
[http://www.orafaq.com/wiki/SQL*Loader_FAQ]
Hope this help.
Best regards,
Jean-Valentin -
How to read a CSV file into the portal
hi all,
I want to read the content of CSV file that is avaliable in my desktop.
plz help me with suitable code
Regards
Savitha
Edited by: Savitha S R on Jun 1, 2009 8:25 AMPlease use this code for that
REPORT znkp_upload_csv line-size 400.
DATA : v_filename TYPE string.
PARAMETER : p_file LIKE rlgrap-filename DEFAULT 'C:\Documents and Settings\Administrator\Desktop\JV.csv' .
*Types for Reading CSV file
TYPES : BEGIN OF x_csv,
text(400) TYPE c,
END OF x_csv.
*Global internal table for reading CSV file
DATA : lt_csv TYPE TABLE OF x_csv.
*Global work area for reading CSV file
DATA : wa_csv LIKE LINE OF lt_csv.
v_filename = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = v_filename
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = lt_csv
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
DATA : BEGIN OF item OCCURS 0 ,
t1(20) TYPE c,
t2(20) TYPE c,
t3(20) TYPE c,
t4(20) TYPE c,
t5(20) TYPE c,
t6(20) TYPE c,
t7(20) TYPE c,
t8(20) TYPE c,
END OF item.
DATA : txt(1) TYPE c. " 1-Header 2-Item
LOOP AT lt_csv into wa_csv.
split wa_csv-text at ',' into item-t1
item-t2
item-t3
item-t4
item-t5
item-t6
item-t7
item-t8.
append item.
clear item.
ENDLOOP.
Check ITEM TABLE
Regards
Naresh -
Upload Csv files with infopackages - Error 1
Hello again,
i'm trying to upload csv file into a infopackage with master data text but the sistem sends a error message "Error 1 uploading external data".
Infopackage settings:
source system: PC
file type: data file
csv file
data separator ;
ESC signal "
a created a txt file with data separated with ; and later converted txt file into a csv file.
can anybody help me pls?
Thanks
Silvia MarquesHi Silvia,
If the fields are correct in the transfer structure (only 2 fields). Then check whether the field length and type has been defined correctly for both the fields.
If thats not a problem then try to load only upto PSA.
If you are using IDOC as your transfer method then go to the "details" tab of the monitor of the error request and see the details. It will give you the correct picture of the error.
Bye
Dinesh.
Maybe you are looking for
-
How to make my Portal Web Service SECURED?
Hi Experts, I created one portal Service and exposed it as Portal Web Service. Everything is working fine, as i deployed my Portal Web Service on to the SAP J2EE Engine ie SAP Server. I m able to access functions of Web Service from my StandAlone Jav
-
TRANSFER PHOTOS FROM IPHONE 5 TO IPHOTO
Is there another way to transfer photos taken from iPhone 5 to iPhoto other than having to connect to the computer directly with USB? Thanks
-
Photo uploading error in Portal
HI Experts, I have configured the ARCHIVELINK to store the photo in Content Server. Manage to upload the photo and display the photo in PA20/30 from the backend ECC system. but my requirement is when we click and go back to same screen where we uploa
-
WLS10 - message-driven bean init-suspended / max-suspended params
I have a message-driven bean deployed with my app. I also have a custom start-up class that binds an Oracle AQ to Weblogic's JNDI tree that this message-driven bean connects to. If our DBAs perform database maintanance over the weekend and bring the
-
TV out Preferences revert back NTSC to PAL
When I play a movie on my iPhone and using TV Out to show it on my TV, during the movie the settings a changed automatically and NTSC is reverting back to PAL. Does anyone know why is it happening and how can I resolve it? Thanks, Hadar.