Uploading csv files and reading them from server

I want to read a csv file.From Flex i am able to select the
file but when i pass it to the server using struts
FileUploadInterceptor , am not able to pass the file to the
server.FileUploadInterceptor in struts2 processes the request only
if its instance of MultiPartRequestWrapper.Is there any way in Flex
where i can pass the request as a instance of this.Is there any
other way in which i can read the file from the server after
uploading it through flex.Code is as follows :
1)MXML File :
?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script>
<![CDATA[
import ImportData;
import flash.net.FileReference;
import flash.net.FileFilter;
import flash.events.IOErrorEvent;
[Bindable] var fileRef:FileReference = new FileReference();
private function openFileDialog():void{
fileRef.addEventListener(Event.SELECT, selectHandler);
fileRef.addEventListener(Event.COMPLETE, completeHandler);
fileRef.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA
,uploadCompleteHandler);
fileRef.addEventListener(IOErrorEvent.IO_ERROR,onIOError);
try{
var textTypes:FileFilter = new FileFilter("Text Files
(*.txt,*.csv)","*.txt;*.csv");
var allTypes:Array = new Array(textTypes);
//var success:Boolean = fileRef.browse();
var success:Boolean = fileRef.browse(allTypes);
catch(error:Error){
trace("Unable to browse for files.");
private function onIOError(event:IOErrorEvent):void {
trace("In here"+event.text);
trace("In here"+event.toString());
// when a file is selected you upload the file to the upload
script on the server
private function selectHandler(event:Event):void{
//var request:URLRequest = new URLRequest("/importAction");
var request:URLRequest = new URLRequest("
http://localhost:8080/pack1/importAction.action");
try
fileRef.upload(request);
catch (error:Error)
trace("Unable to upload file.");
private function completeHandler(event:Event):void{
trace("uploaded");
// dispatched when file has been uploaded to the server
script and a response is returned from the server
// event.data contains the response returned by your server
script
public function uploadCompleteHandler(event:DataEvent):void
trace("uploaded... response from server: \n" +
String(event.data));
]]>
</mx:Script>
<mx:Button label="Import" id="importBtn"
click="openFileDialog()" height="20" width="90"
styleName="buttonsOnSearchBar"/>
<mx:ComboBox x="23" y="44" borderColor="#ff0000"
themeColor="#ff0000"></mx:ComboBox>
</mx:Application>
2)struts.xml file
<struts>
<package name="pack1"
extends="struts-default,json-default">
<global-results>
<result name="error" type="json"></result>
</global-results>
<global-exception-mappings>
<exception-mapping result="error"
exception="java.lang.Throwable"/>
</global-exception-mappings>
<action name="importAction"
class="routing.ImportAction">
<interceptor-ref name="fileUpload"/>
<interceptor-ref name="basicStack"/>
<result name="success" type="json"></result>
</action>
</package>
</struts>
3)Action Class
package com.om.dh.orderrouting.action;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import org.apache.log4j.Logger;
import com.opensymphony.xwork2.ActionSupport;
public class ImportAction extends ActionSupport{
private String contentType;
private File upload;
private String fileName;
private String caption;
private static final Logger logger =
Logger.getLogger(ImportAction.class);
@Override
public String execute() throws Exception {
* Read File Line by Line.. If the file has more than one
word separated by comma
* return error.
ArrayList<String> symbolList = new
ArrayList<String>();
try{
BufferedReader reader = new BufferedReader(new
FileReader(upload));
String line =null;
String symbol=null;
while((line=reader.readLine())!=null){
StringTokenizer tokenizer = new StringTokenizer(line,"\t");
symbol = tokenizer.nextToken();
if(symbol!=null) symbol = symbol.trim();
if(symbol.length()>0)
symbolList.add(symbol);
}catch(FileNotFoundException fne){
if(logger.isDebugEnabled())
logger.debug("File NotFount ", fne);
for(String symbol1:symbolList)
System.out.print(symbol1+" ");
return SUCCESS;
public String getUploadFileName() {
return fileName;
public void setUploadFileName(String fileName) {
this.fileName = fileName;
public String getUploadContentType() {
return contentType;
public void setUploadContentType(String contentType) {
this.contentType = contentType;
public File getUpload() {
return upload;
public void setUpload(File upload) {
this.upload = upload;
public String getCaption() {
return caption;
public void setCaption(String caption) {
this.caption = caption;
public String input() throws Exception {
return SUCCESS;
public String upload() throws Exception {
return SUCCESS;

quote:
Originally posted by:
ived
tried this but does not work...
var request:URLRequest = new URLRequest("
http://localhost:8080/pack1/importAction.action");
request.contentType="multipart/form-data";
in the interceptor it expects the request to be instanceof
MultiPartRequestWrapper...
Further the document says that FileReference.upload() and
FileReference.download() methods do not support the
URLRequest.contentType and URLRequest.requestHeaders parameters.
Any help ??

Similar Messages

  • Uploading Excel File and Reading Data from that File

    <b>Hi
    Can anyone Please tell me how to upload an Excel File in to the Web Dynpro Application and After that i want to read the data from that uploaded excel file in the Web Dynpro Application to the Web Dynpro table.
    Plz help me to solve this.......
    Regards
    Chandran</b>

    Hi,
    Upload Excel file using File Upload UI
    1)Add jxl jar folder in the lib folder of ur project.
    2)Go to properties of ur project and add jar to ur project.
    3)Using the File upload ui ,browse and upload the file.
    4)Write the read file in to ur server location using fileoutput stream.
    5)then using code u can read the excelfile from the server location itself.
    Here is the code:
         IWDAttributeInfo attInfo =wdContext.getNodeInfo().getAttribute("upload");
    /** get the name of excel file and storing it in the server with the same name and extention****/
    binaryType=IWDModifiableBinaryTypeattInfo.getModifiableSimpleType();
    fileuploaded = binaryType.getFileName();
    byte b[] = wdContext.currentContextElement().getUpload();
    File filename =new File("
    <Server name>
    <folde name>
    " + fileuploaded);
    try {
    FileOutputStream out = new FileOutputStream(filename);
    out.write(b);
    out.close();
    } catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    /**Readind from the server**/
    int iRows = 0;
    try {     Workbook wb = null;
         Sheet sheet = null;
         wb = Workbook.getWorkbook(filename);
         sheet = wb.getSheet(0);
         int iColumns = sheet.getColumns();
          iRows = sheet.getRows();
         int i = 0;
        //get Cell contents by (COLUMN, ROW);
        for (int r = 0; r < iRows; r++) {
       for (int c = 0; c < iColumns; c++) {
         Cell cell = sheet.getCell(c, r);
         characterarray<i> = cell.getContents();
    //wdComponentAPI.getMessageManager().reportSuccess("Row"r characterarray<i>);
    i++;
    wb.close();
    Declare Globally
    //@@begin others
    String fileuploaded;
    IWDModifiableBinaryType binaryType;
    String characterarray[] = new String[1000];
    //@@end
    Also look at this blog too  /people/perumal.kanthan/blog/2005/03/21/reading-excel-data-from-java-using-hssf-api
    Thanks and Regards,
    Arun

  • Read a csv file and read the fiscal yr in the 4th pos?

    Hello ABAP Experts,
    how to write a code for read a csv file and read the fiscal year in the 4th position.
    any suggestions or code highly appreciated.
    Thanks,
    BWer

    Hi Bwer,
    Declare table itab with the required fields...
    Use GUI UPLOAD to get the contents of the file (say abc.csv) in case if the file is on the presentation server...
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename                        = 'c:\abc.csv'
       FILETYPE                        = 'ASC'
        WRITE_FIELD_SEPARATOR           = 'X'
      tables
        data_tab                        = itab
    EXCEPTIONS
       FILE_WRITE_ERROR                = 1
       NO_BATCH                        = 2
       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.
    Use OPEN DATASET in case if the file is on the application server..
    After that USE SPLIT command at comma to get the contents of the 4th field...
    Regards,
    Tanveer.
    <b>Please mark helpful answers</b>

  • How do I process multiple files and turn them from raw to jpeg

    How do I process multiple files and turn them from raw to jpeg. Ive tried and it seems to go through the files but doesnt seem to process them or store them in the selected folder

    Yes that was the first thing I did. Then I used the process multiple files and selected a new folder to put them in and selected use open files and selected to turn them into jpeg. The images flash on the screen like they are being processed, but the folder never appears in library. Is it possible because there are a couple 16 bit files open that this corrupts the task. Do I need to create the folder first. Will elements not create the folder on its own.
    Thanks Vince

  • Feature Request: save metadata to file, and read metadata from file.

    Please have function to save metadata to file, and read metadata from file.
    This would allow us to write cross-platform plugins that can assure data is up-to-date in the xmp, or modify xmp and have it reinstated in the catalog.
    This would go nicely with the ability to save xmp for virtual copies, dng, and rgb formats.

    Perhaps someone with direct experience with publishing to Smugmug will chime in.  Short of that, some thoughts on your issues:
    Should I not bother to "Save Metadata to File", this seems to be what is messing up the SmugMug publish service?
    I very much doubt that it is messing up the publishing.  What gets saved to the file from the catalog is independent of what gets exported.  Saving metadata to the file is generally a good practice (in case you screw up your catalog backups).  Many, perhaps most, users set the preference Catalog Settings > Automatically Write Changes Into XMP.
    I would have expected it to behave like an export which would write synonyms, exclude keywords that should be excluded, etc, which seems to work ok in point 6 above.
    Yes, that's a reasonable expectation.
    You may have done this already, but double-check: Right-click the Smugmug publishing service in the left-hand column of the Library, select Edit Settings, and in the Metadata section verify that you have Include: All Metadata set.
    Did you download the Smugmug plugin from Smugmug? You might try this Smugmug plugin instead -- the author designed the publishing architecture of LR and has an excellent reputation. 
    Are the publish services more effort than they are worth? So I get SmugMug to work, what happens when I try Flickr?
    I think many users find the publishing services are generally worthwhile.  I publish regularly to Flickr (using the built-in Flickr plugin, which isn't completely reliable) and the Zenfolio plugin from Friedl. 

  • Is there a way to select a certain box of elements from a csv file and read that into LabVIEW?

    Hello all, I was wondering if there was a way to select only a certain "box" of elements from a .csv file in LabVIEW? I have LabVIEW 2011 and my main goal is to take two arrays and graph them against each other. I can import the .csv file just fine and separate each row and each column to be its own, but say I have an 8X8 but want to graph the middle 4X5 or something like that. Is there any way to extract an array without starting at the beginning and without ending at the end? Thank you in advance.
    Solved!
    Go to Solution.

    Hi Szklanam,
    as a CSV file is just a TXT file with a different suffix you can read a certain number of lines of that file. So you can limit the number of rows in your resultung array. To limit the number of columns you still have to use ArraySubset, so maybe it's a lot easier to read the full CSV file and pick the interesting spots with ArraySubset...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • How to import a csv file and read  in sap ui5?

    Hi,
    I want to import a file and read it contents to bind it to table.How to do it?
    Thanks in advance.

    I tried to do this all from within the application but found it easier to just start with a JSON file. But, you can use a JS library to convert your CSV into JSON from within the application like this one:
    archan937/csonv.js · GitHub
    I just converted my CSV to JSON. Once you have that, all you need to do is instantiate a model for it and bind to table.
      onInit: function () {
        var oModel = new sap.ui.model.json.JSONModel("PATH TO YOUR JSON FILE");
        this.getView().setModel(oModel);
      <Table id="idProductsTable"
        inset="false"
        items="{
          path: '/ProductCollection',
          sorter: {
            path: 'Name'
        }">
    The UI5 demo kit is a good resource. I believe it'll be same/similar for SAPUI5:
    OpenUI5 SDK - Demo Kit
    See here for example of defining your model and binding to a table:
    sap.m Explored

  • Upload csv file and insert into a table for user

    Hello,
    i want to create a Page on which, the User of my Application can upload a semicolon delimited file and the data of the file should automatically be stored in a table.
    I can upload the file and the file is then stored in the htmldb_application_files table.
    But I do not no how to parse the file....
    Can anyone help me or is there anyone who have done that before?
    Thank you,
    Tim

    Tim...
    Here is what I did in a similar situation.
    Let the user download a csv file to use as an excel turnaround document.
    I check digit the primary key. They are not supposed to touch that column.
    They do their excel thing adding data in columns next to the ones they are updating. They now have the original and new data on the same row in the excel document. They save it on a share drive as a csv. A perl script wakes up and parses the csv. Verify's the check digit, checks that the old values still exist in the table... etc, and then does the update if all is well at the row level. The csv is replaced showing the success or failure of the update on each row.
    Probably lots of other ways to accomplish this but I have gotten years of use out of the script. The original csv can come out of almost any application. Mine come from apex, discoverer and some excel queries.
    Bob

  • Upload audio files and share them for free

    I would like to upload audio files onto ITunes.  I would like to do this at work so that I can share it with whomever wants to listen to them for free.  Is this possible?  If so, how many audio and or visual files can I upload, what would the duration of the video be and would I have copyright to these files?
    Thank you,
    Ashifa

    Unfortunately, LE7 doesn't include what you need, although (pre-Apple) Logic Audio 6 did - the EXS Instrument Editor. Keymap, from Redmatica, is a more robust editor, but it hasn't been released yet (second half of 2005, according to their site).
    I don't know of any others, maybe someone else here does.

  • Can you access files and edit them from different computers in Creative Cloud?

    I want to understand the workflow we can have. We have three computers and would like to access and edit the same files in Creative Cloud. Can you do this? I understand I may have to purchase two licenses but will this give everyone access to the same files and able to edit and upload files.
    We do this in Dropbox now but with Creative Cloud is sounds like all I can do is share a file for them to comment on, not edit?

    Hi Olivia,
    With Creative Cloud, file editing comes in via downloading Adobe applications with a Creative Cloud membership. While you cannot edit within Creative Cloud, you can share files with your coworkers which can then be downloaded, edited in an Adobe application, and reuploaded to the Cloud.
    Be aware that although you can have two computers activated on the same Creative Cloud membership, you cannot use the same application on two computers simultaneously. A Creative Cloud membership is for one user that can be used on one or more computers.
    You may want to look into the Creative Cloud Team Ready, that targets work environments like yours. You can read more about Team Ready here.
    Hope this helped clarify your questions!

  • Dynamicall create csv files and zip them

    Apex version - 4.2
    I have some data in the database. I want to generate multiple csv files dynamically from those data. Then zip the csv files together to provide it to the end user.
    Can anybody suggest with the approach that could be followed.
    Thanx in advance !

    Find some code to generate the csv, for instance Export and save result set in CSV format using UTL_FILE
    Find some code to zip the files/blobs, for instance http://technology.amis.nl/2010/06/09/parsing-a-microsoft-word-docx-and-unzip-zipfiles-with-plsql/
    Combine the two pieces
    Done

  • How to compile other java files and run them from my own programs?

    I'm developing a unit testing tool for AspectJ, which can originally generate the stubs for aspect unit to be tested. All these stubs are java files. After generation of stubs, how can I program the code to compile this unit together with these stubs, i.e. how can I put the functionality of compilation and run, e.g. command "javac *.java" and "java *", into my own code.
    Hope you can understand what I mean.
    Thank you in advance.

    When I use Runtime.getRuntime().exec(command) for executing the AspectJ compile command "ajc", "IOException createProcess error=2" always occurs, while it is ok for Java comiple command "javac".
    Why this happens when I use Runtime.getRuntime().exec("ajc Hello.java Test.aj")? Is it the reason that Runtime.exec(String) may not support any command in DOS?
    (ajc is the compile command for the java file and aj file.)
    Thank you in advance.

  • Is there a way to store PDF files and read them on your iPhone?

    I noticed that you can read PDF files on the Internet, but it takes a bit of time to appear. Another problem was that it is hard to scroll because you can only scroll about one page at a time with the finger flicking.
    Also is it possible to have portable browser on your iPhone?

    Well, sounds like you may be stuck---some potential approaches:
    Look at the file sharing apps to see if any offer special PDF features like bookmarks or saving your place (FileMagnet, AirSharing, etc, there are lots of them). You can even add bookmarks in Preview, though I have no idea whether any other app can read them. I know reading PDFs as email attachments does not save your place--I would expect some other apps to do better with that.
    See if Calibre does any better with images in conversion:
    http://calibre.kovidgoyal.net/
    Run OCR software on Google's PDF to convert it to text.
    Since Google does a text search on them, the text is somewhere. Though maybe only Google can access it, it may not be in the PDF file but stored separately.
    For some books, Google Books offers an HTML or plain text version. See if you can download that one instead (may still want to convert via Stanza).
    See if some of the books you want might be in Gutenberg:
    http://www.gutenberg.org/

  • How to install pdf files and read them in nokia 63...

    tried copyin pdf file in nokia 6300 and tried opening it d phone..but it came as file format not supported..help me..

    sorry, your phone is 6300, idont attention to it.
    your phone dosnt have os(s40) with this information and you cant to install this program.
    General 2G Network GSM 900 / 1800 / 1900
    GSM 850 / 1800 / 1900 - US version
    Announced 2006, November
    Status Available. Released 2007, January
    Size Dimensions 106.4 x 43.6 x 11.7 mm, 56 cc
    Weight 91 g
    Display Type TFT, 16M colors
    Size 240 x 320 pixels, 31 x 41 mm
    - Downloadable wallpapers, screensavers
    Ringtones Type Polyphonic (64 channels), MP3
    Customization Download, order now
    Vibration Yes
    Memory Phonebook 1000 entries, Photocall
    Call records 20 dialed, 20 received, 20 missed calls
    Card slot microSD (TransFlash), up to 2GB, buy memory
    - 7.8 MB of user memory
    Data GPRS Class 10 (4+1/3+2 slots), 32 - 48 kbps
    HSCSD Yes
    EDGE Class 10, 236.8 kbps
    3G No
    WLAN No
    Bluetooth Yes, v2.0
    Infrared port No
    USB Yes, miniUSB
    Features Messaging SMS, MMS, Email, Instant Messaging
    Browser WAP 2.0/xHTML
    Games Yes + Downloadable, order now
    Colors Silver, Black, Red-Silver, White-Silver
    Camera 2 MP, 1600x1200 pixels, video(QCIF)
    - Java MIDP 2.0
    - FM stereo radio
    - Push to talk
    - MP3/MP4/AAC/AAC+/eAAC+ player
    - Voice memo
    - Voice command
    - T9
    - Calendar
    - Calculator
    - Built-in handsfree
    Battery Standard battery, Li-Ion 860 mAh (BL-4C)
    Stand-by Up to 348 h
    Talk time Up to 3 h 30 min
    NOKIA means:Night Of King In Alone

  • Uploading CSV File into Web Dynpro Java Table and Write back to a Database

    Hi Gurus!
    I would like to upload a csv file and read the content into an UI table element.
    Then, I need to write the uploaded file back to a database. I'm using NetWeaver 2004s.
    could you please provide advice for both, uploading and wirting to databse (e.g. maxDB or oracle), since I'm quite new in WDJ.
    thanks in advance.
    farid
    ps. helpfull answers will be rewarded with points!

    Hi ,
    have look at this blog
    https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/6603. [original link is broken] [original link is broken] [original link is broken]
    Have a look at this links.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a4d71.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c0d9336b-b4cf-2910-bdbf-b00d89bd2929.
    Re: Popup Internal Window - data type IWDWindow not available
    Regards,
    krishna.

Maybe you are looking for