Formatted file input of integers
I can see how to do low-level file i/o and how to read in
strings in Lingo, but I have a long list/array of numbers(
integers) that I want to read into the program from a file once and
for all at the start of the movie. Then later, I want to use these
integers to control the movie display. Is there any easy way to do
formatted file reads in Lingo, or do I have to write my own
number-parsing routine? Thanks for any help.
John
Here are a couple of handlers that should return a string
whose value() is the original list:
on GetStringList(aList)
-- INPUT: <aList> should be a linear or property list
-- OUTPUT: Returns a string whose value is the original
list. The
-- use of embedded quotes in strings and the appearance of
-- <Void> are explicitly treated. Void in sublists
will
-- be correctly treated, but strings with embedded quotes
-- will only be treated in the outermost values
if listP(aList) then
aList = aList.duplicate() -- so that we don't change the
original
i = aList.count
repeat while i
tValue = aList
case ilk(tValue) of
#string:
if tValue contains QUOTE then
-- Replace embedded quotes
aList =
ReplaceAll(tValue,QUOTE,QUOTE&""E&""E)
end if
end case
i = i - 1
end repeat
end if
tString = string(aList)
-- Replace any occurrences of <Void> with Void
tString = ReplaceAll(tString, "<Void>", "Void")
return tString
end GetStringList
on ReplaceAll(aString, aSubString, aReplacement)
-- INPUT: <aString> is the main string to search in
-- <aSubString> is a string which may appear in
<aString>
-- <aReplacement> is a string which is to replace all
-- occurrences of <aSubString> in <aString>
-- OUTPUT: returns an updated version of <aString>
where all
-- occurrences of <aSubString> have been replaced by
-- <aReplacement>
if aSubString = "" then
return aString
end if
tTreatedString = ""
tLengthAdjust = the number of chars of aSubString - 1
repeat while TRUE
tOffset = offset(aSubString, aString)
if tOffset then
if tOffset - 1 then
put chars(aString, 1, (tOffset - 1)) after tTreatedString
end if
put aReplacement after tTreatedString
delete char 1 to (tOffset + tLengthAdjust) of aString
else -- there are no more occurrences
put aString after tTreatedString
return tTreatedString
end if
end repeat
end ReplaceAll
Similar Messages
-
Hi All,
Am using OPENROWSET to load the file data into table, here the problem is i need to map same input value to two different columns of table, As format file doesn't allow the duplicate numbers am unable to insert same value to two columns, please help me to
find a solution for this.
i can use only OPENROWSET because i need to insert some default values also which come based on file. only the problem is how to map same input value to two different columns of table. please give me the suggestions.
Thanks,
SudhakarFrom what you say:
INSERT tbl(col1, col2)
SELECT col1, col1
FROM OPENROWSET(....)
But I guess it is more difficult. You need to give more details. What sort of data source do you have? What does your query look like? The target table?
Erland Sommarskog, SQL Server MVP, [email protected]
Hi Erland,
Thanks for your response
my source file is text file with | symbol separate for ex:
1002|eTab |V101|eTablet|V100|Logic|LT-7|Laptops|SCM
Database table have columns like
column1,column2,column3...etc, now i need to insert same value from input file into two columns for ex:
the eTab value from text file has to be insert into column2 and column3 of
table
we cannot change format file like below one
for the above situation how can we insert eTab into column2 and column3
Thanks,
Sudhakar. -
Auto generated types and ps1xml formatting files
Hello,
I'm using New-WebServiceProxy to work with a web service... when I call methods of the web service powershell auto generates types, for example, things like "Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1_webservices_awebservicepage_asmx.TheMethodReturnObjectType"
1. should I just use that type name in my ps1xml formatting file? I'm wondering if that will be fragile... seems fragile like 'webServiceProxy1' for example, what if there is some scenario it uses '2'? Not sure if I can count on that being consistent?
2. I started creating custom objects and adding my own type name to them so that type name could be used in the ps1xml file. This works fine. However so far it was for web service methods that returned single instance results.. now I hit a point where I'm
calling a web service method that will return a collection... so I'm wondering if it would be better to just use the auto generated type name in the ps1xml or, as I would need to do in this case, actually enter a foreach loop to create a new custom object
for every object in the returned collection? In other words, for the web service methods I've used so far for this, I simply created my custom object and write-output... for the case of the collection, I would be new-object'ing and write-output'ing within
that foreach loop.. wondering about performance issues, or if it's just overkill when I could just put that auto generated type name in the ps1xml file and be done with it...
not sure if I've asked that very clearly...
essentially, I'm wondering if it's overkill (from a resource usage perspective) to be creating these custom objects in the case of when there will be a collection, with potentially hundreds of items, when the only reason I'm doing it is for display purposes...
if it were not an autogenerated type I would simply use the type name in the ps1xml, I'm just not sure if I can do that in this case as I don't know if that typename will *always* be the same?
any input would be appreciated, thanksHi DJC,
I haven't rexperienced this, however, to create a .ps1xml file, these examples may be helpful for you:
Creating a module for powershell with a format file
discutils / utils / DiscUtils.PowerShell / DiscUtils.Format.ps1xml
about_Format.ps1xml
I hope this helps. -
Colum names mapping from formate file is not working
Hi All,
i tried to import data from text file using BULK INSERT format file option, am able to load the data from file to table but when i change the column name order in the input file it is not inserting according to change column order
BULK INSERT monsanto55_Steelwedge_monsanto_manualBuild_filters.dbo.bulk_test
FROM '\\192.168.97.23\poc\bulk.txt'
WITH( FORMATFILE = '\\192.168.97.23\poc\build.fmt',FIRSTROW = 2)
TABLE COLUMS: P_Id,LastName,FirstName,age,Address,City,no
Format file is :
10.0
7
1 SQLCHAR 0 12 "\t" 1 P_Id ""
2 SQLCHAR 0 255 "\t" 2 LastName SQL_Latin1_General_CP1_CI_AS
3 SQLCHAR 0 255 "\t" 3 FirstName SQL_Latin1_General_CP1_CI_AS
4 SQLCHAR 0 12 "\t" 4 age ""
5 SQLCHAR 0 255 "\t" 5 Address SQL_Latin1_General_CP1_CI_AS
6 SQLCHAR 0 255 "\t" 6 City SQL_Latin1_General_CP1_CI_AS
7 SQLCHAR 0 12 "\r\n" 7 no ""
input data file:
P_Id FirstNameLastName
ageAddress Cityno
1 first
one 11
sanathnagar HYD 5
2 second
two 12
xyz abc
0
3 third
three 20
ameerpet SEC
30
according to mapping the data in table must be like:
P_Id,LastName,FirstName,age,Address,City,no
1 one first 11 sanathnagar HYD 5
2 two second 12 xyz abc 0
3 third three 20 ameerpet SEC 30
but it inserting same as input file format so first name and last name are miss matching
please let me know if you have any idea.
Thanks,Hi All,
i tried to import data from text file using BULK INSERT format file option, am able to load the data from file to table but when i change the column name order in the input file it is not inserting according to change column order
BULK INSERT monsanto55_Steelwedge_monsanto_manualBuild_filters.dbo.bulk_test
FROM '\\192.168.97.23\poc\bulk.txt'
WITH( FORMATFILE = '\\192.168.97.23\poc\build.fmt',FIRSTROW = 2)
TABLE COLUMS: P_Id,LastName,FirstName,age,Address,City,no
Format file is :
10.0
7
1 SQLCHAR 0 12 "\t" 1 P_Id ""
2 SQLCHAR 0 255 "\t" 2 LastName SQL_Latin1_General_CP1_CI_AS
3 SQLCHAR 0 255 "\t" 3 FirstName SQL_Latin1_General_CP1_CI_AS
4 SQLCHAR 0 12 "\t" 4 age ""
5 SQLCHAR 0 255 "\t" 5 Address SQL_Latin1_General_CP1_CI_AS
6 SQLCHAR 0 255 "\t" 6 City SQL_Latin1_General_CP1_CI_AS
7 SQLCHAR 0 12 "\r\n" 7 no ""
input data file:
P_Id FirstNameLastName
ageAddress Cityno
1 first
one 11
sanathnagar HYD 5
2 second
two 12
xyz abc
0
3 third
three 20
ameerpet SEC
30
according to mapping the data in table must be like:
P_Id,LastName,FirstName,age,Address,City,no
1 one first 11 sanathnagar HYD 5
2 two second 12 xyz abc 0
3 third three 20 ameerpet SEC 30
but it inserting same as input file format so first name and last name are miss matching
please let me know if you have any idea.
Thanks,
Hi all,
Thanks for your response, and sorry for wrong question here i need to supply default values to column of
table based on input file so default values of columns will be changed based on input file, and one more thing i don't have any rights to change the table structure my work is to load data from file to table. Is there any chance to supply default values by XMLformat
file instead of .fmt file
or any other scenarios please let me know the possibility. -
Hello!
I'm installing a AS JAVA 2004S with EP/EP-CORE and BI_JAVA and got following error during Java Load step. (The installation successfully creates and loads about 1000 tables prior the error).
Regards,
Fredrik
serverXX:/usr/sap/TPQ/ciinst # more jload.java.log
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 2.2)
IBM J9SE VM (build 2.2, J2RE 1.4.2 IBM J9 2.2 Linux amd64-64 j9xa64142-20061124 (JIT enabled)
J9VM - 20061121_1035_LHdSMr
JIT - r7_level20061020_1803)
May 24, 2007 11:39:52 AM com.sap.inst.jload.Jload main
INFO: Jload -sec TPQ,jdbc/pool/TPQ,/usr/sap/TPQ/SYS/global/security/data/SecStore.properties,/usr/sap/TPQ/SYS/global/security/data/Se
cStore.key -dataDir /a_stage/51032257/JAVA_EXPORT/JDMP -job /usr/sap/TPQ/ciinst/IMPORT.XML -log jload.log
May 24, 2007 11:39:53 AM com.sap.inst.jload.db.DBConnection connectViaSecureStore
INFO: connected to TPQ on jdbc/pool/TPQ
May 24, 2007 11:39:53 AM com.sap.inst.jload.JobStatus readStatus
INFO: trying to read status file /usr/sap/TPQ/ciinst/IMPORT.sta
May 24, 2007 11:39:53 AM com.sap.inst.jload.JobStatus readStatus
INFO: commencing restart
May 24, 2007 11:39:53 AM com.sap.inst.jload.Jload dbImport
INFO: trying to delete from table BC_UDDI_PARAM
May 24, 2007 11:39:53 AM com.sap.inst.jload.Jload dbImport
INFO: BC_UDDI_PARAM deleted
May 24, 2007 11:39:53 AM com.sap.inst.jload.Jload dbImport
SEVERE: DB Error during import of BC_UDDI_PARAM
May 24, 2007 11:39:53 AM com.sap.inst.jload.Jload printSQLException
SEVERE: Message: [-3050]: Invalid timestamp format:ISO(input position 83)
May 24, 2007 11:39:53 AM com.sap.inst.jload.Jload printSQLException
SEVERE: SQLState: I3050
May 24, 2007 11:39:53 AM com.sap.inst.jload.Jload printSQLException
SEVERE: ErrorCode: -3050
May 24, 2007 11:39:53 AM com.sap.inst.jload.Jload dbImport
INFO: trying to delete from table BC_XMLA_COL
May 24, 2007 11:39:53 AM com.sap.inst.jload.Jload dbImport
INFO: BC_XMLA_COL deleted
May 24, 2007 11:39:53 AM com.sap.inst.jload.Jload dbImport
SEVERE: DB Error during import of BC_XMLA_COL
May 24, 2007 11:39:53 AM com.sap.inst.jload.Jload printSQLException
SEVERE: Message: [-3050]: Invalid timestamp format:ISO(input position 2)
May 24, 2007 11:39:53 AM com.sap.inst.jload.Jload printSQLException
SEVERE: SQLState: I3050
May 24, 2007 11:39:53 AM com.sap.inst.jload.Jload printSQLException
SEVERE: ErrorCode: -3050
May 24, 2007 11:39:53 AM com.sap.inst.jload.db.DBConnection disconnect
INFO: disconnected
serverXX:/usr/sap/TPQ/ciinst #Hi
yes, I had the same issue and I found a solution.
You need to request a patch for BUG 9212862 (already corrected in WLS 10.3.3) and do the follwing:
javax.xml.ws.BindingProvider provider = (javax.xml.ws.BindingProvider)port;
java.util.Map context = provider.getRequestContext();
context.put(weblogic.wsee.jaxrpc.WLStub.POLICY_COMPATIBILITY_PREFERENCE, weblogic.wsee.jaxrpc.WLStub.POLICY_COMPATIBILITY_MSFT);
This will cause the SecurityMessageArchitect class of WLS to not send the SecurityTokenReference in the Soap security header.
Please note that is evidently a non-comformity to the specs of microsoft:
Please give a look at
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0.pdf (8.3 Signing Tokens)
and also at:
http://www.oasis-open.org/committees/download.php/16768/wss-v1.1-spec-os-SAMLTokenProfile.pdf
(3.4 Identifying and Referencing Security Tokens)
A SAML key identifier reference MUST be used for all (local and remote) references to SAML 1.1
assertions. [...]
All conformant implementations MUST be able to process SAML assertion references occurring in a
<wsse:Security> header or in a header element other than a signature to acquire the corresponding
assertion. A conformant implementation MUST be able to process any such reference independent of the
confirmation method of the referenced assertion.
It follows that the .NET 3.5 is a non conformat implementation: I would gladly know which is the position of Microsoft on that.
ciao
carlo -
How can we give the Data Format (File Type ) in Runtime
Hi all,
How can we give the Data Format (File Type ) in Runtime for the following method,
cl_gui_frontend_services=>gui_download.
Thanks in advance
SriThere is a filetype parameter which you can set
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
* BIN_FILESIZE =
filename =
* FILETYPE = 'ASC'
* APPEND = SPACE
* WRITE_FIELD_SEPARATOR = SPACE
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = SPACE
* WRITE_LF = 'X'
* COL_SELECT = SPACE
* COL_SELECT_MASK = SPACE
* DAT_MODE = SPACE
* CONFIRM_OVERWRITE = SPACE
* NO_AUTH_CHECK = SPACE
* CODEPAGE = SPACE
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = SPACE
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* IMPORTING
* FILELENGTH =
changing
data_tab =
* EXCEPTIONS
* FILE_WRITE_ERROR = 1
* NO_BATCH = 2
* GUI_REFUSE_FILETRANSFER = 3
* INVALID_TYPE = 4
* NO_AUTHORITY = 5
* UNKNOWN_ERROR = 6
* HEADER_NOT_ALLOWED = 7
* SEPARATOR_NOT_ALLOWED = 8
* FILESIZE_NOT_ALLOWED = 9
* HEADER_TOO_LONG = 10
* DP_ERROR_CREATE = 11
* DP_ERROR_SEND = 12
* DP_ERROR_WRITE = 13
* UNKNOWN_DP_ERROR = 14
* ACCESS_DENIED = 15
* DP_OUT_OF_MEMORY = 16
* DISK_FULL = 17
* DP_TIMEOUT = 18
* FILE_NOT_FOUND = 19
* DATAPROVIDER_EXCEPTION = 20
* CONTROL_FLUSH_ERROR = 21
* NOT_SUPPORTED_BY_GUI = 22
* ERROR_NO_GUI = 23
* others = 24 -
How-to use Excel for the XML file input?
Hello all,
Following our discussion with Gerhard Steinhuber on the very nice tutorial from Horst Schaude , "How to upload mass data via XML File Input" , I am starting this new discussion.
In the comments section of this previous cited tutorial, Rufat Gadirov explains how to use a generated XML from Eclipse instead of your XSD file as your source in Excel.
However, in spite of all the instructions, I am still facing the same issue in Excel when I try to save my file as XML : "The XML maps in this workbook are not exportable".
What I try to do is to create one or more Sales Orders with multiple Items in it from a XML File Input, using excel to enter data.
The part with the File input is working (if I directly upload my file to the webDAV, it creates a sales order instance with multiple items).
The only missing part is the Excel data input that I cannot make work. Any help on this matter would be greatly appreciated.
Here is my XML file that I try to use as a source in Excel before inputing data from Excel:
<?xml version="1.0" encoding="UTF-8"?>
<p:MySalesOrderUploadedIntegrationInputRequest xmlns:p="http://001365xxx-one-off.sap.com/YUUD0G3OY_" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MessageHeader>
<CreationDateTime>2015-03-02T12:00:00.000Z</CreationDateTime>
</MessageHeader>
<List actionCode="01" listCompleteTransmissionIndicator="true" reconciliationPeriodCounterValue="0">
<MySalesOrderUploaded>
<MySalesOrderUploadedID>idvalue0</MySalesOrderUploadedID>
<MyBuyerID schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeID="token">token</MyBuyerID>
<MyDateTime>2015-03-02T12:00:00.000Z</MyDateTime>
<MyName languageCode="EN">MyName</MyName>
<MyBillToParty schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyBillToParty>
<MyDateToBeDelivered>2001-01-01</MyDateToBeDelivered>
<MyEmployeeResponsible schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyEmployeeResponsible>
<MySalesUnit schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MySalesUnit>
<MyItem>
<MyItemID>token</MyItemID>
<MyItemProductID schemeAgencyID="token" schemeID="token">token</MyItemProductID>
<MyItemDescription languageCode="EN">MyItemDescription</MyItemDescription>
<MyProductTypeCode>token</MyProductTypeCode>
<MyRequestedQuantity unitCode="token">0.0</MyRequestedQuantity>
<MyConfirmedQuantity unitCode="token">0.0</MyConfirmedQuantity>
<MyNetAmount currencyCode="token">0.0</MyNetAmount>
</MyItem>
</MySalesOrderUploaded>
<MySalesOrderUploaded>
<MySalesOrderUploadedID>idvalue0</MySalesOrderUploadedID>
<MyBuyerID schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeID="token">token</MyBuyerID>
<MyDateTime>2015-03-02T12:00:00.000Z</MyDateTime>
<MyName languageCode="EN">MyName</MyName>
<MyBillToParty schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyBillToParty>
<MyDateToBeDelivered>2001-01-01</MyDateToBeDelivered>
<MyEmployeeResponsible schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyEmployeeResponsible>
<MySalesUnit schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MySalesUnit>
<MyItem>
<MyItemID>token</MyItemID>
<MyItemProductID schemeAgencyID="token" schemeID="token">token</MyItemProductID>
<MyItemDescription languageCode="EN">MyItemDescription</MyItemDescription>
<MyProductTypeCode>token</MyProductTypeCode>
<MyRequestedQuantity unitCode="token">0.0</MyRequestedQuantity>
<MyConfirmedQuantity unitCode="token">0.0</MyConfirmedQuantity>
<MyNetAmount currencyCode="token">0.0</MyNetAmount>
</MyItem>
</MySalesOrderUploaded>
</List>
</p:MySalesOrderUploadedIntegrationInputRequest>
Thank you all for your attention.
Best regards.
Jacques-Antoine OllierHello Jacques-Antoine,
I suppose that as you have tried to construct a map from the schema, you have taken the elements from the List level down. In this case I also can't export the map.
But if you take the elements from the level MySalesOrderUploaded down, you'll get the exportable map (screenshots)
Best regards,
Leonid Granatstein -
Getting parameters from text and file input tag. . canyou help me ?
Hello!
Is there anyway of getting parameters from an
text field input in a form like :
<form name="signinForm" method="post" action="uploadFile.jsp" enctype="multipart/form-data" >Actually I would like to insert the parameters and make the upload of an file
on the same form. It is something likethis :
Form.jsp
<form name="signinForm" method="post" action="uploadFile.jsp" enctype="multipart/form-data" >
<input type="text" id="name" name="signinName" />
<input name="signinFile" id="fileUp" type="file" />
<input type="submit" id="submit_btn" name="signinSubmit"/>uploadingFile.jsp
<%@ page import="java.io.*,javax.servlet.http.HttpServletRequest,javax.servlet.ServletInputStream" %>
<%@ page import="java.io.FileWriter,java.io.IOException" %>
<%
.//upload the file
String email = request.getParameter("signinName").trim(); //this line is bringing me an NullPointerException
%>Thanks in advance for any suggestion!!
All the best!You cannot use the HttpServletRequest object to retrieve parameters from a multipart form. You'll have to use a package that can parse such a form. I suggest Apache commons FileUpload.
http://jakarta.apache.org/commons/fileupload/
Using this package you can get both the file upload and any other parameters. -
How to use multiple patterns for masking/format the input text
Hi All,
I am using Jdeveloper 11.1.1.5 and i have a requirement where i need to format my input Text value in these below patterns:-
Format
Example
AA9A 9AA
EC1A 1BB
A9A 9AA
W1A 1HQ
A9 9AA
M1 1AA
B33 8TH
A99 9AA
AA9 9AA
CR2 6XH
DN55 1PT
AA99 9AA
For Example :- If user puts value as EC1A1BB, it should automatically changed to EC1A 1BB
if user puts value as W1A1HQ, it should be automatically changed to W1A 1HQ and so on..
If it could have been one format , i might have followed this :- https://blogs.oracle.com/jdevotnharvest/entry/get_social_security_numbers_right
But for multiple patterns i am not able to get through to the proper solution.
Is there any way to achieve this ? Please suggest.
Regards,
ShahFor the validation you should be able to use one regular expression where you add the logical or (|) (check the doc http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html) between the groups. If none of the patterns matches you have an error.
For the for formatting I'm not sure you can use only one expression.
I suggest to write one method which does the checking on and the formatting may be using an array of patterns to check and iterate the patterns in a loop. Once you found a match you can read the needed format from another array (or an other dimension if you prefer to use a multidimensional array).
Timo -
Passing request of file input type to a jsp
Hi i m using this script for file uploading the form is.... <html > <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form action="uploadscript.jsp" name="filesForm" enctype="multipart/form-data" method="post">
Please specify a file, or a set of files:
<input type="file" name="userfile_parent" value="userfile_parent" >
<input type="submit" value="submit" value="Send">
</form> </body> </html> And i am tring to get the url on uploadscript.jsp by using String parentPath=request.getParameter("userfile_parent"); but i foud that its value is NULL it is not working what should i do to get the userfile_parent on uploadscript.jsp help me!!! Message was edited by: UDAY Message was edited by: UDAY
avajain
Posts: 135
From: Noida , India
Registered: 5/10/06
Read Re: Passing response but getting NULL
Posted: Sep 20, 2006 2:43 AM in response to: UDAY in response to: UDAY
Click to reply to this thread Reply
Use method="GET" in place of method="post" .
Thanks
UDAY
Posts: 26
From: JAIPUR
Registered: 8/14/06
Read Re: Passing response but getting NULL
Posted: Sep 20, 2006 3:18 AM in response to: avajain in response to: avajain
Click to edit this message... Click to reply to this thread Reply
now it is giving this error message by e.getMessage()
[br]the request doesn't contain a multipart/form-data or multipart/mixed stream, content type header is null
the uploadscript is this....
http://www.one.esmartstudent.com
can u please help me.Here is sample code which we have used in one of our projects with org.apache.commons.fileupload.*.
You can find String fullName = (String) formValues.get("FULLNAMES"); at the end that gives name of file.
<%@ page import="java.util.*"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.Iterator"%>
<%@ page import="java.io.File"%>
<%@ page import="java.io.*"%>
<%@ page import="org.apache.commons.fileupload.*"%>
<%@ page import="org.apache.commons.fileupload.disk.*"%>
<%@ page import="org.apache.commons.fileupload.servlet.*"%>
<%!
//method to return file extension
String getFileExt(String xPath){
//Find extension
int dotindex = 0; //extension character position
dotindex = xPath.lastIndexOf('.');
if (dotindex == -1){ // no extension
return "";
int slashindex = 0; //seperator character position
slashindex = Math.max(xPath.lastIndexOf('/'),xPath.lastIndexOf('\\'));
if (slashindex == -1){ // no seperator characters in string
return xPath.substring(dotindex);
if (dotindex < slashindex){ //check last "." character is not before last seperator
return "";
return xPath.substring(dotindex);
%>
<%
Map formValues = new HashMap();
String fileName = "";
boolean uploaded = false;
// Check that we have a file upload request
boolean isMultipart = FileUpload.isMultipartContent(request);
//Create variables for path, filename and extension
String newFilePath = CoeResourceBundle.getEmailProperties("FILE_UPLOAD_PATH");//application.getRealPath("/")+"temp";
String newFileName ="";
String FileExt = "";
//System.out.println(" newFilePath"+newFilePath+"/");
//out.println(" newFilePath"+newFilePath+"<br>");
// Create a factory for disk-based file items
FileItemFactory factory = new DiskFileItemFactory();
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
// Parse the request
List /* FileItem */ items = upload.parseRequest(request);
// System.out.println(" newFilePath"+newFilePath+"/");
// Process the uploaded items
Iterator iter = items.iterator();
//Form fields
while (iter.hasNext()) {
//System.out.println("in iterator");
FileItem item = (FileItem) iter.next();
if (item.isFormField()) {
String name = item.getFieldName();
String value = item.getString();
if (name.equals("newFileName")) {
newFileName = value;
//System.out.println("LOADING");
formValues.put(name,value);
else {
//System.out.println("in iterator----");
String fieldName = item.getFieldName();
fileName = item.getName();
int index = fileName.lastIndexOf("\\");
if(index != -1)
fileName = fileName.substring(index + 1);
else
fileName = fileName;
FileExt = getFileExt(fileName);
String contentType = item.getContentType();
boolean isInMemory = item.isInMemory();
long sizeInBytes = item.getSize();
if (fileName.equals("") || sizeInBytes==0){
out.println("Not a valid file.<br>No upload attempted.<br><br>");
} else {
// out.println("ACTUAL fileName= " newFilePath"\\"+fileName+ "<br>");
//File uploadedFile = new File(newFilePath+"\\", newFileName+FileExt);
File uploadedFile = new File(newFilePath+"/",fileName);
File oldFile = new File(CoeResourceBundle.getEmailProperties("FILE_UPLOAD_PATH")+"/"+fileName);
File oldFileApproved = new File(CoeResourceBundle.getEmailProperties("APPROVED_FILE_LOCATION")+"/"+fileName);
try{
if (!oldFile.exists()&&!oldFileApproved.exists())
item.write(uploadedFile);
uploaded = true;
//out.println(fileName+" was successfully uploaded as "+ newFileName+FileExt +".<br><br>");
catch (java.lang.Exception e) {
out.println("Errors prevented the file upload.<br>"+fileName+ " was not uploaded.<br><br>");
String userid = (String) formValues.get("USERID");
String fullName = (String) formValues.get("FULLNAMES");
String email = (String) formValues.get("EMAILID");
String empno = (String) formValues.get("EMPNO");
String docType = (String) formValues.get("DOCTYPE");
String desc = (String) formValues.get("MYTEXT");
String title = (String) formValues.get("TITLEBOX");
String module = (String) formValues.get("MODULE");
String techfunctype = (String) formValues.get("TECHFUNCTYPE");
%> -
How to parse CSV format files in CPO?
Hi,
Not able to read the csv format file in CPO.
I need to loop through each line of the csv file, and retrieve each field by splitting with ','
Can anybody help me in this?
Thanks,
SwatiUse the "Read Table from Text" activity. Here's a thread: https://supportforums.cisco.com/message/3570542#3570542
-
I am using Photoshop Elements 11. Do all .jpg formatted file have to be retangular in shape? I want to create an oval .jpg picture to insert into a book. Haven't been able to do so. It would work if I could make the area outside the oval completely transparent. Can anyone help me here?
JPG does not support transparency, so even if you create an oval with transparent background, the saved JPG will have white background. Instead, save it as a PNG, TIFF, or GIF which preserve the transparency.
Here is one of many ways to create your oval:
Create a new file the approximate size of the oval. Add the oval with the Custom Shape Ellipse tool, and simplify the shape layer.
In the Layers Palette, Ctrl-click the oval to select it and copy the selection to the clipboard (Edit > Copy).
Then do File > New from Clipboard. This creates the oval with transparent background cropped to the oval size.
Then save it as one of the file types that support transparency (and also supported by the application where you are sending the picture to).
Note: Is is not even necessary to do step 2. That is only if some reason you want the oval to be tightly cropped. It is sufficient to delete the Background layer in step 1 (or turn off its visibility) and save the file. The oval will appear correctly in the book with either version. -
How to send a mail in pdf format file in sbwp??
how to send a mail in pdf format file in sbwp?? and how to read the content of the mail?
Refer the following link for Sample Program:
http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm -
Format file error, can't fix it!
Hello, I need to import data from text file.I'm using BULK INSERT + format file because I need to skip some fields in my data file.
But I can't fix error appearing during query execution, I've tried to find the answer in the Internet, but didn't succeed.
This is my text datafile: (example of record: 12 fields delimited by $, row is terminated with $ too, some of them are empty as you can see from this example))
5045669$1007449353$PS$TEAM$1$TRY$$$$UNKNOWN$$21226$
This is the format of my table in database:
[id, name, transaction_id] created with the following query:
USE MyDB;
GO
CREATE TABLE dbo.table1
id int NOT NULL,
name varchar(50) NOT NULL,
transaction_id int PRIMARY KEY NOT NULL
GO
in this table:
"transaction_id" should match 1st field in datafile (5045669 in my example)
"name" = 4th field (TEAM in my example)
"id" = 2nd field in datafile (1007449353 in ex.)
all other fields must be skipped.
I use myformat.fmt file, created manually:
9.0
12
2 SQLINT 0 4 "$" 1 id ""
4 SQLCHAR 2 50 "$" 2 name SQL_Latin1_General_CP1_CI_AS
3 SQLCHAR 2 50 "$" 0 Extra SQL_Latin1_General_CP1_CI_AS
1 SQLINT 0 4 "$" 3 transaction_id ""
5 SQLINT 0 4 "$" 0 Extra ""
6 SQLCHAR 2 50 "$" 0 Extra SQL_Latin1_General_CP1_CI_AS
7 SQLCHAR 2 50 "$" 0 Extra SQL_Latin1_General_CP1_CI_AS
8 SQLCHAR 2 8 "$" 0 Extra SQL_Latin1_General_CP1_CI_AS
9 SQLCHAR 2 8 "$" 0 Extra SQL_Latin1_General_CP1_CI_AS
10 SQLINT 0 4 "$" 0 Extra ""
11 SQLINT 0 4 "$" 0 Extra ""
12 SQLINT 0 4 "$" 0 Extra ""
I'm doing my import using this query:
BULK INSERT MyDB.dbo.table1
FROM 'C:\Documents and Settings\Наташа\project\data\data.TXT'
WITH (FIELDTERMINATOR='$', ROWTERMINATOR='$',
FORMATFILE='C:\Documents and Settings\Наташа\project\data\myformat.fmt');
GO
but I obtain the following error:
Msg 4823, Level 16, State 1, Line 1
Cannot bulk load. Invalid column number in the format file "C:\Documents and Settings\Наташа\project\data\myformat.fmt".
I don't know how to fix it! I tried to check whether I was inprecise while creating format file, but it seems to me that everything is correct, I've put myformat.fmt into the same directory with my text datafile (it was in "C:\SQL Server Management Studio\Projects" folder initially), but I still get this error.
Help me, pleaseNatasit,
Is this still an issue?
Thanks!
Ed Price, Power BI & SQL Server Customer Program Manager (Blog,
Small Basic,
Wiki Ninjas,
Wiki)
Answer an interesting question?
Create a wiki article about it! -
FM - gui_upload. Problems uploading CSV format file
Hi experts,
I am facing an issue here. I tried to upload a .csv format file using FM - gui_load, in the table LT_RAW all the information is all in one column and rest of the columns are empty.
How can i get the information to its respective fields?
below are my codes:
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = pv_file
READ_BY_LINE = 'X'
HAS_FIELD_SEPARATOR = 'X'
codepage = '4110'
IMPORTING
filelength = lv_filelength
TABLES
data_tab = lt_raw
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.
I can only upload using .CSV format.Hi Suhas,
below is the new code that i used. now the data is not filled in only one column,
Instead it will fill up the max length of the field and continue the data in other field and fill up its max length of the field.
" my declaration of lt_raw and ls_raw
lt_raw TYPE TABLE OF ZCTD_MIGCUSTOMER,
ls_raw like line of lt_raw,
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = pv_file
codepage = '4110'
IMPORTING
filelength = lv_filelength
TABLES
data_tab = lt_raw
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.
Maybe you are looking for
-
I guess this is my last ditch effor to fix this computer. All HP computers I've ever had had a hidden partition from where I could recover the computer, but this one doesn't. I think it's too old or something. It is a: Presario V5000 (But I think t
-
What do you think of my Bash Script? What about the error checking?
Well what do you think of this Bash script It works I gave it some problems (i.e. unpluged the ethernet, messed up the URL's, uninstaled some programs...) to see if would report errors and stop or just keep going... But it did I just kind of thought
-
Anyone else getting a sync error when streaming HD movies using "Videos" over the HDMI connection to my Sony Bravia HD TV ?
-
Links in .pdf work for some, not others
Hello all, I've tried a search on the forums to see if my question might already have been answered, but I didn't find anything, and was hoping someone here might have an idea for me: I have two users, each using Adobe Pro 9.1.1 and IE 7.0.5730.13.
-
Hello Experts, Is there a Standard FM to get the Vendor Address when we have Vendor Number? Thanks a lot.