How to delete 1st 2 rows in a csv/excel file?

Hi,
Is there a way to read a csv file and delete the 1st 2 rows  (or any no. of rows I would like to)?
I'm currently using Ben Nadel's GREAT piece of code (Parsing CSV Values into a Coldfusion query) found at http://www.bennadel.com/index.cfm?dax=blog:501.view as follows:
<!--- Read file --->
<cffile action="read" file="#variables.uploadedFile#" variable="csvResult">
<!--- Invoke method to convert csv data to query --->
<cfinvoke component="components.csvToQuery" method="CSVToQuery" returnvariable="qCsvData">
     <cfinvokeargument name="CSV" value="#trim(variables.csvResult)#">
     <cfinvokeargument name="FirstRowIsHeadings" value="true">
</cfinvoke>
I need to manipulate qCsvData to delete the 1st 2 rows.
Any ideas would be most welcome.
Thanks and regards,
Yogesh Mahadnac

Hi Joseph,
Thanks again for your brilliant answer!
I still need you help by the way, if you don't mind, of course!
I've based myself on your logic and tried to implement it differently.
(apologies if it's a bit complicated. it's almost 1 o'clock in the morning here, and sleep is getting over...)
Here is what I've done:
Now, I know that I need to ignore the 1st 2 rows, which means, my headers in fact start on the 3rd row.
I've created my column names dynamically and then added rows to my query object.
<cffunction name="removeRecords" returntype="Query" output="false" description="I remove records from a query.">
     <cfargument name="queryObject" type="Query" required="true" hint="Query to remove records from" />
     <!--- Initialise function local variables --->
     <cfset var myQry = QueryNew("")>
     <cfset var i = 0>
     <cfset var j = 0>
     <cfset var columnName = "">
     <cfset var columnList = "">
     <cfset var tempList = arguments.queryObject.columnList>
    <!--- Loop query --->
    <cfloop index="i" from="1" to="#arguments.queryObject.recordcount#">
        <!--- Ignore 1st 2 rows, 3rd row is header --->
        <cfif i gt 2>
            <cfif i eq 3><!--- Create headers --->
                <!--- Loop column list (column_1, column_10, ...) --->
                <cfloop index="j" from="1" to="#listLen(tempList)#">
                    <cfset item = ListGetAt(tempList,j)>
                    <!--- Remove blank spaces --->
                    <cfset columnName = replaceNoCase(trim(arguments.queryObject[item][i])," ","_","All")>
                    <!--- Remove slash --->
                    <cfset columnName = replaceNoCase(trim(columnName),"/","_","All")>
                    <!--- Create column name --->
                    <cfset QueryAddColumn(myQry,columnName,"cf_sql_varchar",ArrayNew(1))>
                    <!--- Create list of column names --->
                    <cfset columnList = columnList & columnName & ",">
                </cfloop>
                <!--- Remove trailing comma --->
                <cfset columnList = left(columnList,len(columnList)-1)>
            <cfelse><!--- As from 4th row, we add 1 new row to myQry for each iteration --->
                <!--- Add rows --->
                <cfset QueryAddRow(myQry)>
                <cfloop index="j" from="1" to="#listLen(tempList)#">
                    <cfset item = ListGetAt(tempList,j)>
                    <cfset fieldValue = trim(arguments.queryObject[item][i])>
                    <cfset col = listGetAt(columnList,j)>
                    <cfset QuerySetCell(myQry,col,fieldValue)>
                </cfloop>
            </cfif>
        </cfif>
    </cfloop>
     <cfreturn myQry>
</cffunction>
Question:
Is there a simpler way to do the following?
<cfset columnName = replaceNoCase(trim(arguments.queryObject[item][i])," ","_","All")>
<cfset columnName = replaceNoCase(trim(columnName),"/","_","All")>
I'm trying to replace all blank spaces and any "/"  between words with an "_".
I know we can use Regular Expressions to do it much simpler, but I'm not very familiar with the syntax.
I'd be grateful if you could please provide me with the correct syntax.
Thanks in advance.
Best regards,
Yogesh

Similar Messages

  • How to delete a row in the table in servlets

    I have met a problem in deleting a row in table using servlets.
    My table looks like this:
    ID Name Type
    12 Milienium S
    15 USIA O
    My code looks like this:
    String query = "SELECT * FROM tb_Funds";
    rs = statement.executeQuery(query);
    while(rs.next()) {          
    StdID=rs.getString("FundID");
    StdName=rs.getString("Name");
    StdType=rs.getString("Type");
    out.print("<td><INPUT TYPE=TEXT NAME=
    myName VALUE=" + StdID + "></td>");
    out.print("<td>" + StdName + "</td>");
    out.print("<td>" + StdType + "</td>");
    buf.append("<td>" + "<INPUT TYPE=SUBMIT
    NAME=Delete VALUE=DELETE>" + "</td></tr>");
    There is a delete button in every row. May I know how to delete the row that I want by getting the ID from the table and delete it from the database.
                                       

    Deleting from a table is simple -> delete from tb_funds where id = <value>. Obviously replace <value> with the appropriate ID or use a bind variable (a ?) and prepared statements.
    Are you asking how to pass the id associated with the table row from the browser when the button is pressed?

  • How to delete multiple rows from ADF table

    How to delete multiple rows from ADF table

    Hi,
    best practices when deleting multiple rows is to do this on the business service, not the view layer for performance reasons. When you selected the rows to delete and press submit, then in a managed bean you access thetable instance (put a reference to a managed bean from the table "binding" property") and call getSeletedRowKeys. In JDeveloper 11g, ADF Faces returns the RowKeySet as a Set of List, where each list conatins the server side row key (e.g. oracle.jbo.Key) if you use ADF BC. Then you create a List (ArrayList) with this keys in it and call a method exposed on the business service (through a method activity in ADF) and pass the list as an argument. On the server side you then access the View Object that holds the data and find the row to delte by the keys in the list
    Example 134 here: http://blogs.oracle.com/smuenchadf/examples/#134 provides you with the code
    Frank

  • How To Delete a Row From a TableView !!!!

    Hi,
    Does any know how to delete a row from a table view model.
    I have a TableViewModel being displayed, when the user select the particular row and click delete i want that particular row to be deleted.
    Any Suggestions How.
    Thanks,
    Emmanuel.

    If u want to delete single row, then set the property of TableView - selectionMode="SINGLESELECT". Select the radio button and click on delete button. In the main program, you can get the row value like...
    public void onDeleteButtonClicked(Event event) throws PageException {
    TableView table = (TableView) this.getComponentByName ("idTableView");
    DefaultTableViewModel dmodel = myBean.beanModel;
    String pid = "", row_selected;
    // Get the first visible row
    int firstVisibleRow = table.getVisibleFirstRow();
    // Get the last visible row
    int lastVisibleRow = table.getVisibleLastRow();
    for (int i = firstVisibleRow; i <= lastVisibleRow; i++) {
    if (table.isRowSelected(i)) {
      row_selected = i;
      pid = dmodel.getValueAt(i, 1).toString();
    "i" will give you the row no, pid has the value of the row at first column.
    Hope this helps.
    Thanks,
    Praveen

  • How to Delete duplicates rows without using rowid/distinct.

    How to delete duplicates rows present in a table without using rowid or even distinct.

    How about:
    SQL> SELECT * FROM t1;
             A          B
             1          2
             2          3
             1          2
             4          4
             4          4
             4          4
    SQL> DELETE FROM t1
      2  WHERE (a, b) IN (SELECT a, b FROM t1
      3                   GROUP BY a, b
      4                   HAVING COUNT(*) > 1) and
      5        rownum = 1;
    1 row deleted.
    SQL> /
    1 row deleted.
    SQL> /
    1 row deleted.
    SQL> /
    0 rows deleted.
    SQL> SELECT * FROM t1;
             A          B
             2          3
             1          2
             4          4Although, if I was asked a similar question with all those restrictions, my first response would be along the lines of: Is this question indicative of the way I will have to work if I join this company? If so, there is no point answering because I wouldn't touch this job with a ten foot pole.

  • How can I create an csv/excel file using pl/sql and then sending that file

    How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
    I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.

    968776 wrote:
    How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
    I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.You are trying to do it at a wrong place..
    Whay do you want database (pl/sql) code to do these things?
    Anyhow, you may be interested in :
    {message:id=9360007}
    {message:id=9984244}

  • How to export the text edit data to excel file without splitting the data in excel file?

    how to export the text edit data to excel file without splitting the data in excel file?
    I have a requirement in SAP HR where in the appraiser can add comments in the area given and can export that to excel file. Currently the file is getting exported but the comments getting split into deifferent rows.
    I want the entire comment to be fit in one row.
    Please help.
    Thank you

    Hi,
    if your text edit value is stored in 'lv_string' variable.
    then before exporting the value to excel you have to remove CL_ABAP_CHAR_UTILITIES=>NEWLINE
    that is '#' from the variable lv_string.
    for that use code some thing like this.
    REPLACE ALL OCCURRENCES OF CL_ABAP_CHAR_UTILITIES=>NEWLINE in lv_string WITH space.
    I think this will do the trick.

  • How do I save a PDF as an excel file when the PDF is horizontal. Adobe tries to rotate the page, but the data is entered in an  horizontal format.

    How do I save a PDF as an excel file when the PDF is horizontal. Adobe tries to rotate the page, but the data is entered in an  horizontal format.

    Thanks for the quick reply.  I figured out how to get the desired results by using tagging.  For anyone who may reference this post in the future, I went to "Customize" in the top right corner of Adobe, then selected "Create new tool set...", looked under "accessiblity and found the "tag" option.  Hit ok, tag is added to the toolbar.  Then I highlighted the dataset in the PDF that was relevant to the output format, then clicked "tag", saved as spreadsheet.  Sorry I can't provide more details on how tagging works or if there's a more elegant solution available, but I'm sure one's out there.

  • How do we scan for viruses of uploaded excel file in Web Dynpro for JAVA

    Hi All,
    Please let me know "How do we scan for viruses of uploaded excel file in Web Dynpro for JAVA"
    Regards,
    Ganga.

    Hi ,
    pl go through this note "Integrating a virus scan into SAP applications 817623 "
    SAP Virus Scan Interface
    http://help.sap.com/saphelp_nw2004s/helpdata/en/30/42c13a38b44d5e8d1b140794e8e850/frameset.htm
    Sample Application
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/6e1c4221-0901-0010-63ba-b1f9459d6e74
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f2681486-0a01-0010-8497-c778eac80da5
    Regards
    Ayyappparaj

  • Adding rows to an existing Excel File.

    Hey,
    I need to be able to add rows to an existing Excel File. I just wanted to know what are my options here.. any sample VIs already existing?
    any help is appreciated.
    Regars,
    Pete

    Yes, the Report Generation Toolkit works very well for this (active x underlies).  You can use the Write to Spreadsheet File.VI to append data to an Excel file.  But keep in mind this file is text-based and not a true Excel file.  That doesn't mean much unless you want manipulate the file with Active X, in which case you will have problems (such as col width, for instance).  If you have Report Generation Toolkit, use it.  It's very easy and flexible.
    Reese, (former CLAD, future CLD)
    Some people call me the Space Cowboy!
    Some call me the gangster of love.
    Some people call me MoReese!
    ...I'm right here baby, right here, right here, right here at home

  • How to ignore 1st row form the file(csv) sender CC

    Hi,
    I have a CSV File (File sender) that I need to load with PI.I want to Ignore 1st row from the file.
    For example the File contains 10 rows  but PI  need to read  the data from 2nd row.
    because in the 1st row contains header data like name, number, mobile, address, etc., I don't want to read this 1st row. I want to read only the data which starts from the 2nd row.
    can you pls tell me the ignore command File Receiver CC
    I am using these commands.
    Record structure: item,*
    item.fieldSeparator: ,
    item.endSeparator : 'nl'
    item.fieldNames:   Name, Number, Address, Mobile
    Thanks in Adv
    Vankadoath

    Hi Vankadoath,
    In your content conversion use the field document offset which ignores the number of lines to be ignored.
    for example if you provide the value as "1" for document offset it will ignore the first line in your file.
    (Under Document Offset, specify the number of lines that are to be ignored at the beginning of the document.
    This enables you to skip comment lines or column names during processing.
    Regards,
    Naveen.

  • How to delete a row in target when corresponding row in source is deleted

    Greetings
    Environment:
    Repository - OWB 10.1.0.4 - going to 10gR2 very soon
    - IBM RS6000 running AIX 5.3
    I have a target table being updated with an INSERT/UPDATE. The user deleted a row in the source table and I want to delete the corresponding row in the target table.
    How do I do this in the map?
    Many thanks.
    -gary

    Thanks very much for the responses. Now that I have thought it through more carefully I see I can still have a single instance of the source table and send it through the MINUS operator with the target table followed by a DELETE into the target table and still have the existing logic for the INSERT/UPDATE into a second occurrence of the target table.
    It won't matter what order OWB puts together the two operations on the target table:
    - if it does the DELETE first the new rows that haven't been added to the target table will come out of the MINUS operator but not be found yet in the target table so not deleted.
    - if it does the INSERT/UPDATE first the newly added rows will not come out of the MINUS operator and hence not deleted from the target.
    Must have been a brain fart.
    Thanks again.
    -gary

  • HOW TO DELETE THE ROW FROM DATABASE

    hI,
    Iam pasting my code below.My problem isi retrieve rows from database and display them in jsp page in rows.For each row there is delete hyperlink.Now when i click that link i should only delete the row corresponding to that delete link temporarily but it should not delete the row from database now.It should only delete the row from database when i click the save button.How can i do this can any one give some code.
    thanks
    naveen
    [email protected]
    <%@ page language="java" import="Utils.*,java.sql.*,SQLCon.ConnectionPool,java.util.Vector,java.util.StringTokenizer" %>
    <html>
    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>Item Details</title>
    <script>
    function submitPage()
    document.details.action = "itemdetails.jsp" ;
    document.details.submit();
    </script>
    </head>
    <body>
    <form name="details" action="itemdetails.jsp" method="post">
    <%
    ConnectionPool pool;
    Connection con = null;
    Statement st;
    ResultSet rs =null;
    %>
    <table border="0" cellpadding="0" cellspacing="0" width="328">
    <tr>
    <td width="323" colspan="4"><b>Reference No :</b> <input type="text" name="txt_refno" size="14">
    <input type="submit" value="search" name="search" ></td>
    </tr>
    <tr>
    <td width="81" bgcolor="#000099"><font color="#FFFFFF"><b>Item Code</b></font></td>
    <td width="81" bgcolor="#000099"><font color="#FFFFFF"><b>Item No</b></font></td>
    <td width="81" bgcolor="#000099"><font color="#FFFFFF"><b>Amount </b></font></td>
    <td width="80" bgcolor="#000099"> </td>
    </tr>
    <%
    pool= new ConnectionPool();
    Utils utils = new Utils();
    double total =0.00;
    String search =utils.returnString(request.getParameter("search"));
    if(search.equals("search"))
    try
    String ref_no =utils.returnString(request.getParameter("txt_refno"));
    String strSQL="select * from ref_table where refno='" + ref_no + "' ";
    con = pool.getConnection();
    st=con.createStatement();
    rs = st.executeQuery(strSQL);
    while(rs.next())
    String itemcode=rs.getString(2);
    int item_no=rs.getInt(3);
    double amount= rs.getDouble(4);
    total= total + amount;
    %>
    <tr>
    <td width="81"><input type=hidden name=hitem value=<%=itemcode%>><%=itemcode%></td>
    <td width="81"><input type=hidden name=hitemno value=<%=item_no%>><%=item_no%></td>
    <td width="81"><input type=hidden name=hamount value=<%=amount%>><%=amount%></td>
    <td width="80"><a href="delete</td>
    </tr>
    <%
    }catch(Exception e){}
    finally {
    if (con != null) pool.returnConnection(con);
    %>
    <tr>
    <td width="323" colspan="4">
    <p align="right"><b>Total:</b><input type="text" name="txt_total" size="10" value="<%=total%>"></td>
    </tr>
    <tr>
    <td width="323" colspan="4">                   
    <input type="button" value="save" name="save"></td>
    </tr>
    </table>
    </form>
    </body>
    </html>

    You mean when you click on the hyperlink you want that row to disappear from the page, but not delete the row from the database until a commit/submit button is pressed?
    Personally, I think I'd prefer that you have a delete checkbox next to every row and NOT remove them from the display if I was a user. You give your users a chance to change their mind about their choice, and when they're done they can see exactly which rows will be deleted before they commit.
    You know your problem, of course, so you might have a good reason for designing it this way. But I'd prefer not removing them from the display. JMO - MOD

  • How to delete a row in ADF Table by pressing "Delete" Key

    I want to delete a row in my ADF table by pressing the "Delete" key..How can i achieve it?

    hai ,
    I write clientListener and ServerListener..But in the script i printed the event.getKeyCode() ...*When i press Delete Key or EnterKey ,it is not printing the value*..
    The code i write is pasted below..
    In the code backing_Comm is my backingbean..Is there any problem in the code that i had written?I want to delete a selected row from my table using keypress Event...pls advice..
    <script type="text/javascript">
    onPressDeleteKey=function(event){
    alert(event.getKeyCode()); // *Here i am not getting the alert, when i press Delete Key or Enter Key..But getting alert when i press A- Z or 1 - 0*
    if(event.getKeyCode()==AdfKeyStroke.ENTER_KEY) {
    var source = event.getSource();
    AdfCustomEvent.queue(source,performDeleteOnPress,{},false);
    </script>
    <*af:table* value="#{bindings.ComMastVO.collectionModel}"
    var="row"
    rows="#{bindings.ComMastVO.rangeSize}"
    emptyText="#{bindings.ComMastVO.viewable ? 'No rows yet.' : 'Access Denied.'}"
    fetchSize="#{bindings.CompMastVO.rangeSize}"
    rowSelection="single"
    id="tblCom"
    columnStretching="last" inlineStyle="width:100%;"
    width="273"
    selectionListener="#{backing_Comm.rowSelectCom}"
    binding="#{backing_Comm.tblCom}"
    clientComponent="true" >
    <*af:column* sortProperty="Com" sortable="true">
    <*af:inputText* value="#{row.bindings.Com.inputValue}"
    label="#{bindings.ComMastVO.hints.Com.label}"
    required="#{bindings.ComMastVO.hints.Com.mandatory}"
    columns="150"
    maximumLength="#{bindings.ComMastVO.hints.Com.precision}"
    shortDesc="#{bindings.ComMastVO.hints.Com.tooltip}">
    valueChangeListener="#{backing_Comm.onValueChange}"
    autoSubmit="true" >
    <f:validator binding="#{row.bindings.Com.validator}"/>
    *</af:inputText>*
    *<af:serverListener type="performDeleteOnPress"*
    *method="#{backing_Comm.goDeleteCurrentRow}"/>*
    </af:column>
    *<af:clientListener type="keyPress"*
    *method="onPressDeleteKey"/>*
    </af:table>
    =================================================
    anybody pls help??
    Edited by: Briston Thomas on Jun 3, 2009 2:25 AM

  • How To Delete a row from view object

    Hi
    I have a table whose data is populated based on the view object... and for each row i have a delete icon...
    when i press on this delete icon i want to delete that particular row from the view object only..but not from the data
    base..please help me in this issue
    Thanks

    Hi,
    as per krishna priya says u can delete .
    -----1st one thing let me know vo is eo based .???.
    If not here is the sample code to delete a row not from the data base.:
    public void Deleterow(OAPageContext pageContext, OAWebBean webBean,String prjid)
    int idtodelete;
    int fetchedrowcount;
    Number prjojectid;
    RowSetIterator deleteIter;
    prjidtodelete=Integer.parseInt(prjid);
    OADBTransaction tr = getOADBTransaction();
    ProjectsVORowImpl row=null;
    ProjectsVOImpl vo= getProjectsVO1();
    fetchedrowcount=vo.getRowCount();
    deleteIter = vo.createRowSetIterator("deleteIter");
    deleteIter.setRangeStart(0);
    deleteIter.setRangeSize(fetchedrowcount);
    for(int i=0;i<fetchedrowcount;i++)
    row= (ProjectsVORowImpl)deleteIter.getRowAtRangeIndex(i);
    prjojectid=(Number)row.getAttribute("ProjectId");
    if (prjojectid.compareTo(prjidtodelete)==0)
    row.remove();
    break;
    deleteIter.closeRowSetIterator();
    Regards
    Meher Irk
    Edited by: Meher Irk on Nov 2, 2010 12:42 AM

Maybe you are looking for

  • No Message: InfoCube Update Completed

    BW Gurus, I trying to load Data from PSA to the Cube Using DTP...during the data load, for certain data package the data load is keep on going and there is no error message as such and its still yellow status and under the "Updating to InfoCube ZXX_X

  • IPhone 3GS crashed, What can I do?

    First of, yes I know, I still have an iPhone 3GS!!!! Anyway, today I just recently updated it to IOS 6(Which I love the new layout). After a few hours of using it, I turned on my music and started temple run. It crashed! I've played temple run and li

  • Jsp & java

    Hi, can I write a java program (.class file) working with swing and called by jsp page (.jsp)

  • Multilple Data entry profiles in ESS for CATS

    hi, We are implementing CATS and configured the data entry profiles in IMG. Can u tell me if multiple data entry profiles can be chosen by employees through ESS webdynpro applcaition. I need this as the screen layouts for an employee logging time to

  • Quality Inspection in WM

    Dear All, I have 2 questions: 1) I want to receive materials under quality inspection during MIGO. How? I only managed to do it by entering Q at the PO. 2) After receiving quantities in quality inspection, how to transfer them in Unrestricted in WM?