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

Similar Messages

  • 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 to import an .csv file into the database?

    and can we code the program in JSP to import the.csv file into the database.

    It is better to use Java class to read the CSV file and store the contents in the database.
    You can use JSP to upload the CSV file to the server if you want, but don't use it to perform database operations.
    JSPs are good for displaying information on the front-end, and for displaying HTML forms, there are other technologies more suitable for the middle layer, back end and the database layer.
    So break you application into
    1) Front end - JSPs to display input html forms and to display data retrieved from the database.
    2) Middle layer - Servlets and JavaBeans to interact with JSPs. The code that reads the CSV file to parse it's contents should be a Java Class in the middle layer. It makes use of Java File I/O
    3) Database layer - Connects to the database using JDBC (Java Database Connectivity), and then writes to the database with SQL insert statements.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Keeping the above concepts in mind, first build a simple JSP and get it to work,
    then research on Google , for Java File I/O , discover how to read a file,
    Then search on how to readh a CSV file using Java.
    After researching you should be able to read the CSV file line by line and store each line inside a Collection.
    Then research on Google, on how to write to the database using JDBC
    Write a simple program that inserts something to a dummy table in the database.
    Then, read the data stored in the Collection, and write insert statements for each records in the collection.

  • 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 Compare 2 CSV file and store the result to 3rd csv file using PowerShell script?

    I want to do the below task using powershell script only.
    I have 2 csv files and I want to compare those two files and I want to store the comparision result to 3rd csv file. Please look at the follwingsnap:
    This image is csv file only. 
    Could you please any one help me.
    Thanks in advance.
    By
    A Path finder 
    JoSwa
    If a post answers your question, please click &quot;Mark As Answer&quot; on that post and &quot;Mark as Helpful&quot;
    Best Online Journal

    Not certain this is what you're after, but this :
    #import the contents of both csv files
    $dbexcel=import-csv c:\dbexcel.csv
    $liveexcel=import-csv C:\liveexcel.csv
    #prepare the output csv and create the headers
    $outputexcel="c:\outputexcel.csv"
    $outputline="Name,Connection Status,Version,DbExcel,LiveExcel"
    $outputline | out-file $outputexcel
    #Loop through each record based on the number of records (assuming equal number in both files)
    for ($i=0; $i -le $dbexcel.Length-1;$i++)
    # Assign the yes / null values to equal the word equivalent
    if ($dbexcel.isavail[$i] -eq "yes") {$dbavail="Available"} else {$dbavail="Unavailable"}
    if ($liveexcel.isavail[$i] -eq "yes") {$liveavail="Available"} else {$liveavail="Unavailable"}
    #create the live of csv content from the two input csv files
    $outputline=$dbexcel.name[$i] + "," + $liveexcel.'connection status'[$i] + "," + $dbexcel.version[$i] + "," + $dbavail + "," + $liveavail
    #output that line to the csv file
    $outputline | out-file $outputexcel -Append
    should do what you're looking for, or give you enough to edit it to your exact need.
    I've assumed that the dbexcel.csv and liveexcel.csv files live in the root of c:\ for this, that they include the header information, and that the outputexcel.csv file will be saved to the same place (including headers).

  • How to import a csv file without "+" being added to numbers?

    I'm trying to import a csv file from my bank. Numbers automatically adds a "+" and "-" sign before all numbers. Numbers won't add the numbers with a + sign. How can I easily remove the + sign? It seems the delimiter in the csv file may be ", rather than , Thanks.

    Wayne,
    I don't believe that the plus sign came from Numbers. Except for a purposful application of a Custom Format, Numbers isn't going to add the plue sign. The minus sign is another issue. It's a perfectly acceptable part of the value and shouldn't cause a problem.
    If the plus sign came from the CSV file, which you seem to imply isn't the case, you would have to strip it out before submitting to Numbers.
    Jerry

  • 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 ??

  • How do Import a csv file that contains strings

    I have a file that contains numbers as US formmated $$$  such as $1,123,123,123  I have a perl script on one of our linux servers that creates the csv file as
    "Total Dollars","$1,123,123,123","some other string","etc"  but when I import the file into numbers
    Unnamed Table
    Average Price'
    $160
    686'
    $222
    482'
    $114
    820'
    $188
    062'
    I cant find a setting anywhere that says to ignore commas inside a string.  This works in most other applications.

    I apologize but you wrote :
    WALTER-MILANO-ITALY wrote:
    You should be now able to import the file using ; as separator or if you prefer you can do again the change  of ; with ,
    It's not a matter of preferences. The OP can't import a file whose values are separated by semi-colons.
    He must replace them by commas.
    With your scheme :
    Original datas
    'Total Dollars','$1,123,123,123','some other string','etc'
    after your step 1
    'Total Dollars';'$1,123,123,123','some other string','etc'
    after your step 2
    'Total Dollars';'$1,123,123,123''some other string''etc'
    and the datas are completly unusable
    A possible scheme would be :
    Original datas
    'Total Dollars','$1,123,123,123','some other string','etc'
    'Totals Dollars','$12,123,123,123’,’blahblah’,’etc'
    after possible step 1 (replace ‘,’ by ",")
    'Total Dollars";"$1,123,123,123";"some other string";"etc'
    'Totals Dollars";"$12,123,123,123";"blahblah";"etc'
    after possible step 2 (replace single ‘ by ")
    "Total Dollars";"$1,123,123,123";"some other string";"etc"
    "Totals Dollars";"$12,123,123,123";"blahblah";"etc"
    after possible step 3 (replace ";" by ",")
    "Total Dollars","$1,123,123,123","some other string","etc"
    "Totals Dollars","$12,123,123,123","blahblah","etc"
    This one may be imported by Numbers on thez OP’s machine.
    I don't know if these changes may be done with Perl but I know that they are easy to do with AppleScript.
    But honestly, if Perl is able to build a TAB separated values file, it would be more efficient.
    Yvan KOENIG (VALLAURIS, France) mercredi 25 janvier 2012
    iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
    My Box account  is : http://www.box.com/s/00qnssoyeq2xvc22ra4k

  • How to import from CSV file into INTERVAL DAY TO SECOND column?

    Hello,
    I need to import data from a csv file that has a column that stores time-intervals (e.g. 2:06:02 Hours:Minutes:Seconds) into a table column INTERVAL DAY TO SECOND.
    Does any of you know what format I should apply?
    I tried HH:MI:SS but it didn't work.
    Any suggestion is welcomed (including changing the column type to something else that might hold time-intervals in it....).
    Thanks,
    Andrei

    Andrei,
    There is no native support for the INTERVAL datatype in the Text loading facilities of Application Express.
    To work around this known limitation, I suggest either creating a temporary table or a shadow column in your existing table. You could then upload your data for the interval as a VARCHAR2 and then use SQL to convert to an appropriate interval value.
    For example:
    1) Create a table with:
    create table foo (id number primary key, i interval day to second, shadowi varchar2(4000) )2) Using your sample data set, load this data into table FOO, loading the second column of this data into column SHADOWI
    1     01:06:02
    2     02:06:02
    3     03:01:013) Issue the following SQL to convert the value in your shadow interval column to your actual interval column
    update foo set i = to_dsinterval( '0 ' || shadowi )Note that you'll need to prepend the '0' to formulate a valid interval literal value.
    Joel

  • How to import a CSV file into Appleworks

    Does anybody knows? I tried using ASCII format (everything goes into one cell), Excel (not recognized). Very fustrated, I can do that in 2 seconds with Excel or Open Office.
    Any help will be really appreciated, must be something really sily

    Roger, you are right. But instead of using a word processort I fixed the file with Perl (much faster in my case):
    auyan:~/Desktop josevnz$ perl -p -i -e 's#,#\t#g; s#\n#\rn#;' 401k-funds-appleworks.csv
    I have to say than Appleworks ***** big time .
    Thanks for your help, very valuable tip!

  • HT4489 how do I import a csv file to icloud?

    Does any one know how to import a .csv file (in Excel) into iCloud so I can transfer my contacts to my iPhone? Thanks!

    This may be a little to late, but you sign on to icloud.com and click contacts, in the bottom right corner there will be the gear simple click that and click import csv.

  • Importing a CSV file into AD 2012r2

    Hi Guys
    Just wondering if anyone can help, I am a newbie on scripting and finding it really difficult to understand how to import a csv file into AD
    I have created the CSV file with the following headers, see below but I am unable to write a powershell script to import them into AD which work, I have tried multiple help guides but still cannot do it for the life of me.
    Any help on this would be really appreciated 
    objectClass user
    cn Jo bloggs
    givenName jo
    sn blogs
    mail [email protected]
    sAMAccountname j.blogs
    AccountPassword Pa$$w0rd
    ChangePasswordAtLogon true
    PasswordNeverExpires false
    ou OU=staff,DC=test,DC=com

    Import-Csv C:\User.csv| %{New-ADUser -SamAccountName $_.SamAccountName `
    -UserPrincipalName $_.userprinicpalname `
    -Name $_.name `
    -Mail = $_.mail `
    -DisplayName $_.name `
    -GivenName $_.GivenName `
    -Path "OU=Test Users,DC=XXX,DC=XXX" `
    -PasswordNeverExpires $false `
    -ChangePasswordAtLogon $true `
    -AccountPassword (ConvertTo-SecureString "test41;" -AsPlainText -force) `
    -Enabled $True -PasswordNeverExpires $True -PassThru ` }
    help New-ADUser -Examples
    You can try the below sample code
    Regards Chen V [MCTS SharePoint 2010]

  • How get output generated as csv file  by reading  by buffered reader and wr

    how get output generated as csv file by reading by buffered reader and writer

    String file_location = "C\temp\csv.txt");
    try {
         URL fileURL = getClass().getResource(file_location);
         if (fileURL != null){
              BufferedReader br = new BufferedReader(new InputStreamReader(fileURL.openStream()));
              String s = br.readLine();
              while (s != null)  {
                   if (!s.equals ("")) {
                        System.out.println(s);
                   s = br.readLine();
              br.close();
         else {
              // error
    catch (IOException ex){ex.printStackTrace();}rykk
    Message was edited by: a dummy
    rykk.

  • Read a CSV file and dynamically generate the insert

    I have a requirement where there are multiple csv's which needs to be exported to a sql table. So far, I am able to read the csv file and generate the insert statement dynamically for selected columns however, the insert statement when passed as a parameter
    to the $cmd.CommandText
    does not evaluate the values
    How to evaluate the string in powershell
    Import-Csv -Path $FileName.FullName | % {
    # Insert statement.
    $insert = "INSERT INTO $Tablename ($ReqColumns) Values ('"
    $valCols='';
    $DataCols='';
    $lists = $ReqColumns.split(",");
    foreach($l in $lists)
    $valCols= $valCols + '$($_.'+$l+')'','''
    #Generate the values statement
    $DataCols=($DataCols+$valCols+')').replace(",')","");
    $insertStr =@("INSERT INTO $Tablename ($ReqColumns) Values ('$($DataCols))")
    #The above statement generate the following insert statement
    #INSERT INTO TMP_APPLE_EXPORT (PRODUCT_ID,QTY_SOLD,QTY_AVAILABLE) Values (' $($_.PRODUCT_ID)','$($_.QTY_SOLD)','$($_.QTY_AVAILABLE)' )
    $cmd.CommandText = $insertStr #does not evaluate the values
    #If the same statement is passed as below then it execute successfully
    #$cmd.CommandText = "INSERT INTO TMP_APL_EXPORT (PRODUCT_ID,QTY_SOLD,QTY_AVAILABLE) Values (' $($_.PRODUCT_ID)','$($_.QTY_SOLD)','$($_.QTY_AVAILABLE)' )"
    #Execute Query
    $cmd.ExecuteNonQuery() | Out-Null
    jyeragi

    Hi Jyeragi,
    To convert the data to the SQL table format, please try this function out-sql:
    out-sql Powershell function - export pipeline contents to a new SQL Server table
    If I have any misunderstanding, please let me know.
    If you have any feedback on our support, please click here.
    Best Regards,
    Anna
    TechNet Community Support

  • Importing CSV file and parsing it

    First of all I am very new to writing powershell code.  Therefore, my question could be very rudimentary, but I cannot find an answer, so please help.
    I'm trying to read a CSV file and parse it.  I cannot figure out how to access nth element without hardcoding its name.
    $data = Import-Csv $file   #import CSV file
    # read column headers (manually read the first row of the data file, or import it from other source, or ...)
    $file_dump = Get-Content $file  #OK, I'm sure there is another way to get just the first line, but that's not relevant
    $name_list = $file_dump[0].split(",")
    # access element
    $temp = $data[$i].Name  # works - but that's HARDCODING the column name into the script - what if someone changes it?
    #but what I want to do is
    $temp = $data[$i].$name_list[0]
    How do I do this in PowerShell?

    So you're asking how to get the first data point from the first column, no matter what the header is?
    Why won't you know what your input file looks like?
    You can always drop the first line of the file to remove the existing headers and then use the -Header parameter of Import-Csv to give yourself known headers to reference (this will only work if you know how many columns to expect, etc etc etc).
    http://ss64.com/ps/import-csv.html
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

Maybe you are looking for

  • My phone wont update apps or let me get new ones

    After my 90 day service warranty or whatever was up my phone wouldn't update my apps. It keeps asking for billing information. The information is correct and i've tried taking the card off my storee account and then back on and nothing. Im at loss of

  • Camera fail after update!

    after last device update the front facing camera is not working or being recognized

  • Restoring My Ipod

    I need to restore my ipod....Which is a pain since we own 5 ipods. My problem with that is that I have toooooo many songs, videos, movies, and apps in my itunes account, since each one of us has different taste, specially with the kids. So I wanted t

  • Map implementation vs. map reference query

    Hello all and Happy New Year. I've written a Map implementation to store and retrieve values for a a class that needs to hold 80,00+ entries; performance is an issue, especially since it's a bucketed map with multiple values mapping to one key. every

  • [SOLVED] KMS error after update

    Yesterday I made an update to Arch (I don't know exactly what was updated), and today, at boot, when KMS activates, the screen stays black, flickering from time to time. Disable KMS doesn't seem to be an option, since I could not start Xorg with KMS