Removing first line in text file... Memory and HD concern

Hello all,
I want to remove the first line of a text file. This is easy... One way
to do it, is to find the first "end of line" caracter, strip the string
and re-write the sting in file with the "strip to sreadsheet" VI.
Since the file can be quite large (about 120000 lines), is this a good
way to do it. Will it re-write all the line or just moving the "begin
of file" pointer to the second line? If it re-write the whole file,
this option is not very good since I could have to do this operation
quite often. (I want the file to be a kind of circular buffer / backup).
What do you think is the best way to do this?
Thanks!
Vincent

I think you would have to read in all the data and write it to a new file, you could either keep the data in RAM or simply write to another file then delete the original, and then rename the temp one.  So obviously that is a lot of data and memory.
My main question is are you trying to use a text file as a circular buffer?  If so can you tell us more about the data, ie is it strings of a constant length?  Does a user ever need to read the file or could we head binary?
A solution would be to truly make the file a binary file, so you could actually seek through the file easier, and maybe make the first data chunk the location of the most recent write.  The obvious danger is then writing over existing data.  This solution is still risky because of the data writes.
You may want to look at some of the other file formats like HWS which maintains a hierarchy of data for you so you can simply add and remove data from it.  However, a user will not be able to easily read it.

Similar Messages

  • Applescript to remove first line from CSV

    Hi,
    I receive CSV files that I then drag and drop into a Numbers spreadsheet.
    The CSV files have two lines of data (which correspond to two rows of data in a Numbers spreadsheet).
    The first line in each CSV is a header that I would like to delete before it goes into the spreadsheet.
    I would like to write an Applescript (application) that I could drop the CSV onto, that would delete the first (header) line.
    Seems like this should be simple, but I've spent the past hour searching for how to do this and I haven't found a clear answer anywhere.
    If anybody could help I'd really appreciate it.
    thanks.

    Saved as an Applescript App, this will delete the first line of text files dropped on the App
    USE WITH CAUTION and Test
    on open the_Files
         repeat with i in the_Files
              tell application "Finder"
                   if name extension of i is "csv" then
                        do shell script "sed  -i \"\" '1 d' " & quoted form of POSIX path of i
                   end if
              end tell
         end repeat
    end open

  • Need help with java File IO ( Removing the first line from a file )

    Hi guys ,
    I am currently doing a project in which I need to extract out the values from the second line of a file to the end. The question is how do I ignore the first line ??
    I thought of two possible answers myself. One is to use randomaccessfile to read and rewrite. But the file may be HUGE so storing the whole file in memory is not a very good idea.
    Second is to jump to second line before doing while ((str = in.readLine()) != EOL) ... or just delete the first line from the file. Can anyone suggest a better solution or show me some sample codes ? Thanks.
    regards
    billyam

    Just skip the first line (bufferedReader.readLine()), add a comment, and then handle the rest of your file

  • Add/Remove Programs - export to text file?

    Hello,
    I am wondering if it is possible to export a list of everything in add/remove programs to a text file for inventory purposes.
    I have not found any easy method to do this short of copying reg files or installer 3rd party software.  Since the idea is to save time neither of those are viable solutions.
    Does anyone have any ideas?
    -Justin

    You could try this vbs script that lists installed programs and add info to a text file.
    Michael Petersen
    Option Explicit  
    Dim sTitle  
    sTitle = "InstalledPrograms.vbs by Bill James" 
    Dim StrComputer  
    strComputer = InputBox("Enter I.P. or name of computer to check for " & _  
                           "installed software (leave blank to check " & _  
                           "local system)." & vbcrlf & vbcrlf & "Remote " & _  
                           "checking only from NT type OS to NT type OS " & _  
                           "with same Admin level UID & PW", sTitle)  
    If IsEmpty(strComputer) Then WScript.Quit  
    strComputer = Trim(strComputer)  
    If strComputer = "" Then strComputer = "." 
    'Wscript.Echo GetAddRemove(strComputer)  
    Dim sCompName : sCompName = GetProbedID(StrComputer)  
    Dim sFileName  
    sFileName = sCompName & "_" & GetDTFileName() & "_Software.txt" 
    Dim s : s = GetAddRemove(strComputer)  
    If WriteFile(s, sFileName) Then 
      'optional prompt for display  
      If MsgBox("Finished processing.  Results saved to " & sFileName & _  
                vbcrlf & vbcrlf & "Do you want to view the results now?", _  
                4 + 32, sTitle) = 6 Then 
        WScript.CreateObject("WScript.Shell").Run sFileName, 9  
      End If 
    End If 
    Function GetAddRemove(sComp)  
      'Function credit to Torgeir Bakken  
      Dim cnt, oReg, sBaseKey, iRC, aSubKeys  
      Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE  
      Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _  
                  sComp & "/root/default:StdRegProv")  
      sBaseKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" 
      iRC = oReg.EnumKey(HKLM, sBaseKey, aSubKeys)  
      Dim sKey, sValue, sTmp, sVersion, sDateValue, sYr, sMth, sDay  
      For Each sKey In aSubKeys  
        iRC = oReg.GetStringValue(HKLM, sBaseKey & sKey, "DisplayName", sValue)  
        If iRC <> 0 Then 
          oReg.GetStringValue HKLM, sBaseKey & sKey, "QuietDisplayName", sValue  
        End If 
        If sValue <> "" Then 
          iRC = oReg.GetStringValue(HKLM, sBaseKey & sKey, _  
                                    "DisplayVersion", sVersion)  
          If sVersion <> "" Then 
            sValue = sValue & vbTab & "Ver: " & sVersion  
          Else 
            sValue = sValue & vbTab   
          End If 
          iRC = oReg.GetStringValue(HKLM, sBaseKey & sKey, _  
                                    "InstallDate", sDateValue)  
          If sDateValue <> "" Then 
            sYr =  Left(sDateValue, 4)  
            sMth = Mid(sDateValue, 5, 2)  
            sDay = Right(sDateValue, 2)  
            'some Registry entries have improper date format  
            On Error Resume Next   
            sDateValue = DateSerial(sYr, sMth, sDay)  
            On Error GoTo 0  
            If sdateValue <> "" Then 
              sValue = sValue & vbTab & "Installed: " & sDateValue  
            End If 
          End If 
          sTmp = sTmp & sValue & vbcrlf  
        cnt = cnt + 1  
        End If 
      Next 
      sTmp = BubbleSort(sTmp)  
      GetAddRemove = "INSTALLED SOFTWARE (" & cnt & ") - " & sCompName & _  
                     " - " & Now() & vbcrlf & vbcrlf & sTmp   
    End Function 
    Function BubbleSort(sTmp)  
      'cheapo bubble sort  
      Dim aTmp, i, j, temp  
      aTmp = Split(sTmp, vbcrlf)    
      For i = UBound(aTmp) - 1 To 0 Step -1  
        For j = 0 to i - 1  
          If LCase(aTmp(j)) > LCase(aTmp(j+1)) Then 
            temp = aTmp(j + 1)  
            aTmp(j + 1) = aTmp(j)  
            aTmp(j) = temp  
          End if  
        Next 
      Next 
      BubbleSort = Join(aTmp, vbcrlf)  
    End Function 
    Function GetProbedID(sComp)  
      Dim objWMIService, colItems, objItem  
      Set objWMIService = GetObject("winmgmts:\\" & sComp & "\root\cimv2")  
      Set colItems = objWMIService.ExecQuery("Select SystemName from " & _  
                                             "Win32_NetworkAdapter",,48)  
      For Each objItem in colItems  
        GetProbedID = objItem.SystemName  
      Next 
    End Function 
    Function GetDTFileName()  
      dim sNow, sMth, sDay, sYr, sHr, sMin, sSec  
      sNow = Now  
      sMth = Right("0" & Month(sNow), 2)  
      sDay = Right("0" & Day(sNow), 2)  
      sYr = Right("00" & Year(sNow), 4)  
      sHr = Right("0" & Hour(sNow), 2)  
      sMin = Right("0" & Minute(sNow), 2)  
      sSec = Right("0" & Second(sNow), 2)  
      GetDTFileName = sMth & sDay & sYr & "_" & sHr & sMin & sSec  
    End Function 
    Function WriteFile(sData, sFileName)  
      Dim fso, OutFile, bWrite  
      bWrite = True 
      Set fso = CreateObject("Scripting.FileSystemObject")  
      On Error Resume Next 
      Set OutFile = fso.OpenTextFile(sFileName, 2, True)  
      'Possibly need a prompt to close the file and one recursion attempt.  
      If Err = 70 Then 
        Wscript.Echo "Could not write to file " & sFileName & ", results " & _  
                     "not saved." & vbcrlf & vbcrlf & "This is probably " & _  
                     "because the file is already open." 
        bWrite = False 
      ElseIf Err Then 
        WScript.Echo err & vbcrlf & err.description  
        bWrite = False 
      End If 
      On Error GoTo 0  
      If bWrite Then 
        OutFile.WriteLine(sData)  
        OutFile.Close  
      End If 
      Set fso = Nothing 
      Set OutFile = Nothing 
      WriteFile = bWrite  
    End Function 
    Deploy deploy deploy

  • How copy just line in text file with cat? (SOLVED)

    Hi.
    How i make to copy just only line in text file with cat?
    For example:
    [:0.0]
    file=/home/Arch/./.wallpaper.png
    mode=0
    bgcolor=# 0 0 0
    I want copy just "/home/Arch/./.wallpaper.png" part.
    Actually i want create a shortcut for last wallpaper set from Nitroget, then i put this in SLim background.
    Recently i use hsetroot for wallpaper (~/.wallpaper.png) and i create a shortcut in /usr/share/slim/theme/MYTHEME whith ln -s ~/.wallpaper.png /usr/share/slim/theme/MYTHEME/background.png.
    I want make a same with Nitrogen.
    I now this looks like crazy, but...
    Sorry my English.
    Last edited by kramerxiita (2008-06-04 16:50:48)

    moljac024 wrote:
    kramerxiita wrote:
    moljac024 wrote:How can you make SliM change the background ? You link the theme background to another file ?
    Yes. In theme directory i put background.png shortcut for my wallpaper. So, when a change wallpaper, slim background change too.
    Example:
    ln -s mywallpaper.png /usr/share/slim/themes/default/background.png
    So, Slim background always is my wallpaper.
    So the wallpaper has to be a *.png ?
    No, jpg is possible. But when you create a symbolic link, remember put the extension too. If change png to jpg, change a symbolic link extension.
    But, remember if slim theme directory have background.png and background.jpg, Slim always choice .png. So, put only one this.

  • The first line in a file is supressed

    hi all,
    i have a really weird problem.
    i have a file with a lot of data and i am using a file adapter with file content conversion to parse it.
    the file adapter is a sender one.
    the problem come when i do read the file and then it ignore the first line of the file.
    all the lines from the second one forward is shown in SXMB_MONI but the first line of the file isn't.
    i can't seem to figure out what the problem is, i tryed looking for some kind of attribute in the file adpater but had no luck.
    could you please help me?
    btw,
    the file structure is: header,1,body1,<wildcard>,body2,<wildcard>
    Edited by: Roi Grossfeld on Oct 29, 2008 4:24 PM

    Recordset Structure: H1,1,B1,<wildcard>,B2,<wildcard>
    Key Field Name: RecordType
    H1.fieldFixedLengths 6,2,8,1,1,3,30,5
    H1.fieldNames FileNo,RecordType,TransmissionDate,Car_Truck,BU,MD,FileName,Count
    H1.keyFieldValue H1
    B1.fieldFixedLengths 6,2,10,27,8,8,4,5,3,11,9,9,11,11,9,9,7,9,11
    B1.fieldNames FileNo,RecordType,InvoiceNumber,VesselName,MMSEShipmentDate,PlanArrivalDate,DeliveryPlace,Units,Currency,ModelPriceAmount,OptionPriceAmount,ColourPriceAmount,REPriceAmount,TotalPriceAmount,FreightChargeAmount,InsuranceFeeAmount,MiscellaneousAmount,VATAmount,GrandTotalAmount
    B1.keyFieldValue B1
    B2.fieldFixedLengths 6,2,10,12,12,12,5,6,12,3,3,3,4,17,7,7,12,8,5,3,9,7,7,9,9,7,9,4,20
    B2.fieldNames FileNo,RecordType,InvoiceNumber,MDOrderNumber,MMSEOrderNumber,MMSECaseNumber,ModelYear,BodyType,Model,ExteriorColourCode,InteriorTrimColourCode,OptionCode,RearEquipment,VehicleIdentificationNumber,ChassisModel,CSequenceNumber,EngineModel,ESequenceNumber,KeyNumber,Currency,UnitModelPrice,UnitOptionPrice,UnitColourPrice,UnitRearEquipmentPrice,UnitTotalPrice,UnitVATAmount,UnitTotalVAT,VATRate,VATNumber
    B2.keyFieldValue B2
    ignoreRecordsetName true
    Edited by: Roi Grossfeld on Oct 29, 2008 4:39 PM

  • How to remove first line of outgoing messages: ?xml version="1.0"........

    On outgoing messages, when I look in MONI, I see properly formatted XML message.
    The first line of all my outgoing files has this line:
    <?xml version="1.0" encoding="UTF-8" ?>
    Is there a way to suppress this?
    If so, is there a way to suppress for only certain partners within one interface?
    Thanks,
    Jeff

    Hi Jeff,
    As others pointed without this line the document will not be a valid document. Can you tell your complete requirment. One of these kind of requirement is discussed in this thread, you can see whether its the same in your case or not. If not then tell your complete req. so that somebody can help you out here.
    Remove first line in the XML Document
    Regards,
    ---Satish

  • How to write empty line in text file

    hey
    i want to insert one empty line in text file.
    how to write this.
    i declared
    data: emptyrec(240) type c value space,
    and used
    TRANSFER emptyrec to e_file.
    but its not inserting empty line in the record.
    is there any special way have to do.
    ambichan.

    hai anand,
    I am posting the code snippet.
    i have commented that transfer line in '----
    ' like this
    pls refer below.
    ambichan
    DATA: PAGENO(4) TYPE N VALUE 1,
          DATAKBN(2) TYPE N VALUE 1,
          SUBNO(3) TYPE N VALUE 1,
          VPAGENO(4) TYPE C,
          VDATAKBN(2) TYPE C,
          VSUBNO(3) TYPE C,
          VREC(255) TYPE C,
          VRECORD(255) TYPE C,
          EMPTYREC(255) TYPE C VALUE SPACE,
          VCODE(10) TYPE C,
          VNAME2(35) TYPE C,
          VPAYDAT(10) TYPE C,
          VSGTXT(60) TYPE C VALUE SPACE,
          VSGTXT1(10) TYPE C,
          VKINGAKU(15) TYPE C VALUE SPACE,
          VBIKKO(30) TYPE C VALUE SPACE,
          VBELNR(10) TYPE C VALUE SPACE,
          VDMBTR(15) TYPE C,
          VGLT0-KSLVT(15) TYPE C,
          VGLT0-TSL01(15) TYPE C,
          VGLT0-TSL02(15) TYPE C,
          VGLT0-TSL03(15) TYPE C,
          VGLT0-TSL04(15) TYPE C,
          VGLT0-TSL05(15) TYPE C,
          VKIN(15) TYPE C,
          VTEGA(15) TYPE C.
    FORM FRM_OUTPUT_DATA.
      SORT ITAB_OUTPUT_SUMMARY BY LIFNR DTYPE.
      SORT ITAB_OUTPUT_ITEMS   BY LIFNR DTYPE BELNR.
    IF P_DISP = 'X'."check&#12508;&#12463;&#12473;&#12434;&#36984;&#12406;&#22580;&#21512;&#12289;&#12501;&#12449;&#12452;&#12523;&#20316;&#25104;&#20966;&#29702;&#12408;&#34892;&#12367;
    OPEN DATASET E_FILE FOR OUTPUT IN TEXT MODE.
      IF SY-SUBRC <> 0.
      WRITE: 'error',SY-SUBRC.
      EXIT.
      ENDIF.
    LOOP AT ITAB_LIFNR.
      PERFORM LISTDATA.
      PAGENO = PAGENO + 1.
      SUBNO = 1.
    ENDLOOP.
    CLOSE DATASET E_FILE."&#12501;&#12449;&#12452;&#12523;&#12463;&#12525;&#12540;&#12474;
    ENDFORM.                               " End of frm_output_data
    FORM LISTDATA.
      DATA:
        WK_PAY_AMOUNT  LIKE  BSEG-DMBTR,   " &#32020;&#25903;&#25173;&#38989;&#31639;&#20986;&#29992;
        VWK_PAY_AMOUNT(15) TYPE C,
        GLT0-TSL05_VAL LIKE GLT0-TSL05.
      READ TABLE ITAB_OUTPUT_SUMMARY
             WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 1.
    BSIK-DMBTR  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      GLT0-TSL01  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      READ TABLE ITAB_OUTPUT_SUMMARY
             WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 2. " &#21306;&#20998;&#65306;2
      GLT0-TSL02  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      READ TABLE ITAB_OUTPUT_SUMMARY
             WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 3. " &#21306;&#20998;&#65306;3
      GLT0-TSL03  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      READ TABLE ITAB_OUTPUT_SUMMARY
             WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 4. " &#21306;&#20998;&#65306;4
      GLT0-TSL04  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      READ TABLE ITAB_OUTPUT_SUMMARY
             WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 5. " &#21306;&#20998;&#65306;5
      GLT0-TSL05  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
    glt0-tsl05  =  glt0-tsl05  +  glt0-tsl04.
      WK_PAY_AMOUNT  =  GLT0-TSL05  +  GLT0-TSL04.
    CHECK WK_SUBRC = 0.                
      BSEG-KOART = ' '.                    &#24773;&#22577;&#19981;&#35201;
      CLEAR: BSEG-SGTXT, BSEG-DMBTR, TGSBT-GTEXT, BKPF-BELNR.
      BSEG-KOART = 'Y'.                    " &#12501;&#12521;&#12464;&#65306;&#12504;&#12483;&#12480;&#12395;&#30456;&#27578;&#38989;&#12434;&#20986;&#21147;
    CLEAR: BSAK-DMBTR.
      READ TABLE ITAB_OUTPUT_SUMMARY
           WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 6.  " &#21306;&#20998;&#65306;6
      BSAK-DMBTR  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      WK_PAY_AMOUNT  =  WK_PAY_AMOUNT  -  BSAK-DMBTR.
      WRITE : / PAGENO,
               SUBNO,
               DATAKBN,
               ITAB_LIFNR-LIFNR,
               ITAB_LIFNR-NAME2(25),
               P_PAY_T,
               GLT0-TSL01,
               GLT0-TSL02,
               GLT0-TSL03,
               GLT0-TSL04,
               GLT0-TSL05.
    VPAGENO = PAGENO.
    VSUBNO = SUBNO.
    DATAKBN = 1.
    VDATAKBN = DATAKBN.
    VCODE = ITAB_LIFNR-LIFNR.
    VNAME2 = ITAB_LIFNR-NAME2.
    VPAYDAT = P_PAY_T.
    VGLT0-TSL01 = GLT0-TSL01.
    VGLT0-TSL02 = GLT0-TSL02.
    VGLT0-TSL03 = GLT0-TSL03.
    VGLT0-TSL04 = GLT0-TSL04.
    VGLT0-TSL05 = GLT0-TSL05.
    CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT VKINGAKU
    VBIKKO VBELNR VGLT0-TSL01 VGLT0-TSL02 VGLT0-TSL03
    VGLT0-TSL04 VGLT0-TSL05 INTO VREC SEPARATED BY ','.
    CLEAR: BSAK-DMBTR, BSID-DMBTR, BSAD-DMBTR, BSEG-DMBTR, BSIK-DMBTR,
             WK_10 , WK_11 , GLT0-TSL05.
      READ TABLE ITAB_OUTPUT_SUMMARY
           WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 7.  " &#21306;&#20998;&#65306;7
      BSID-DMBTR  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      WK_PAY_AMOUNT  =  WK_PAY_AMOUNT  -  BSID-DMBTR.
    &#37109;&#36865;&#26009;&#12398;&#20986;&#21147;&#20966;&#29702;
      READ TABLE ITAB_OUTPUT_SUMMARY
           WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 8.  " &#21306;&#20998;&#65306;8
      BSAD-DMBTR  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      WK_PAY_AMOUNT  =  WK_PAY_AMOUNT  -  BSAD-DMBTR.
      READ TABLE ITAB_OUTPUT_SUMMARY
           WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 9.  " &#21306;&#20998;&#65306;9
      BSEG-DMBTR  =  ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      WK_PAY_AMOUNT  =  WK_PAY_AMOUNT  -  BSEG-DMBTR.
      READ TABLE ITAB_OUTPUT_SUMMARY
             WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 10.
      WK_10 =     ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      READ TABLE ITAB_OUTPUT_SUMMARY
             WITH KEY   LIFNR  =  ITAB_LIFNR-LIFNR  DTYPE = 11.
      WK_11 =     ITAB_OUTPUT_SUMMARY-DMBTR * WK_RATIO.
      GLT0-TSL05  =   WK_PAY_AMOUNT - WK_10 - WK_11.
      WK_PAY_AMOUNT  =  WK_PAY_AMOUNT  -  GLT0-TSL05.
       VWK_PAY_AMOUNT = WK_PAY_AMOUNT.
       VKIN = WK_10.
       VTEGA = WK_11.
       CONCATENATE VREC VWK_PAY_AMOUNT VKIN VTEGA INTO
             VRECORD SEPARATED BY ','.
       TRANSFER VRECORD TO E_FILE.
        WRITE :
                VWK_PAY_AMOUNT,
                WK_10,
                WK_11.
       WRITE:/.
      BSEG-KOART  = 'X'.                   " &#12501;&#12521;&#12464;&#65306;&#35531;&#27714;&#37329;&#38989;&#12434;&#20986;&#21147;
      LOOP AT ITAB_OUTPUT_ITEMS WHERE LIFNR = ITAB_LIFNR-LIFNR
                                AND   DTYPE = 5.          " &#21306;&#20998;&#65306;5
        BSEG-SGTXT   =  ITAB_OUTPUT_ITEMS-SGTXT.          " &#26126;&#32048;&#12486;&#12461;&#12473;&#12488;
        GLT0-KSLVT   =  ITAB_OUTPUT_ITEMS-DMBTR * WK_RATIO.     " &#37329;&#38989;
        TGSBT-GTEXT  =  ITAB_OUTPUT_ITEMS-GTEXT.              BKPF-BELNR   =  ITAB_OUTPUT_ITEMS-BELNR.         
       SUBNO = SUBNO + 1.
       VSUBNO = SUBNO.
       DATAKBN = 2.
       VDATAKBN = DATAKBN.
       VGLT0-KSLVT = GLT0-KSLVT.
       VBIKKO = TGSBT-GTEXT.
       VBELNR = BKPF-BELNR.
       VSGTXT1 ='&#35531;&#27714;&#37329;&#38989;:'.
       CLEAR VRECORD.
      CONCATENATE  VSGTXT1 BSEG-SGTXT INTO VSGTXT.
      CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT
    VGLT0-KSLVT VBIKKO VBELNR INTO VRECORD SEPARATED BY ','.
      TRANSFER VRECORD TO E_FILE.
       WRITE :/ VPAGENO,VSUBNO,VDATAKBN,'&#35531;&#27714;&#37329;&#38989;:', VSGTXT, VGLT0-KSLVT,
                VBIKKO,VBELNR.
      ENDLOOP.
      CLEAR: BSEG-SGTXT,GLT0-KSLVT,BKPF-BELNR.
    LOOP AT ITAB_OUTPUT_ITEMS WHERE LIFNR = ITAB_LIFNR-LIFNR
                                AND   DTYPE = 6.          " &#21306;&#20998;&#65306;6
        BSEG-SGTXT   =  ITAB_OUTPUT_ITEMS-SGTXT.          " &#26126;&#32048;&#12486;&#12461;&#12473;&#12488;
        IF  ITAB_OUTPUT_ITEMS-SHKZG  =  CNS_CREDIT.       " &#37329;&#38989;
          GLT0-KSLVT  =  ITAB_OUTPUT_ITEMS-DMBTR * WK_RATIO.
        ELSEIF  ITAB_OUTPUT_ITEMS-SHKZG  =  CNS_DEBIT.
          GLT0-KSLVT  =  ITAB_OUTPUT_ITEMS-DMBTR * WK_RATIO * -1.
        ENDIF.
      TGSBT-GTEXT  =  ITAB_OUTPUT_ITEMS-GTEXT.          " &#20107;&#26989;&#38936;&#22495;&#12486;&#12461;&#12473;&#12488;
      BKPF-BELNR   =  ITAB_OUTPUT_ITEMS-BELNR.          " &#20253;&#31080;&#30058;&#21495;
      SUBNO = SUBNO + 1.
      VSUBNO = SUBNO.
      DATAKBN = 3.
      VDATAKBN = DATAKBN.
      VGLT0-KSLVT = GLT0-KSLVT.
      VBIKKO = TGSBT-GTEXT.
      VBELNR = BKPF-BELNR.
      VSGTXT1 ='&#30456;&#27578;&#37329;&#38989;:'.
      CLEAR VRECORD.
      CONCATENATE  VSGTXT1 BSEG-SGTXT INTO VSGTXT.
      CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT
      VGLT0-KSLVT VBIKKO VBELNR INTO VRECORD SEPARATED BY ','.
      TRANSFER VRECORD TO E_FILE.
    concatenate vpageno vsubno vdatakbn
      WRITE :/ PAGENO,SUBNO,DATAKBN,'&#30456;&#27578;&#37329;&#38989;',BSEG-SGTXT, GLT0-KSLVT,
             TGSBT-GTEXT, BKPF-BELNR.
      ENDLOOP.
       CLEAR VRECORD.
    *Insert empty line.
      TRANSFER EMPTYREC TO E_FILE.
      DATAKBN = 3.
      VDATAKBN = DATAKBN.
      SUBNO = SUBNO + 1.
      VSUBNO = SUBNO.
      VSGTXT ='&#28304;&#27849;&#37329;&#38989;'.
      VDMBTR = BSID-DMBTR.
      CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT
      VDMBTR INTO VRECORD SEPARATED BY ','.
      TRANSFER VRECORD TO E_FILE.
      WRITE :/ PAGENO, SUBNO,DATAKBN, ITAB_LIFNR-LIFNR,ITAB_LIFNR-NAME2,
             P_PAY_T,'&#28304;&#27849;&#37329;&#38989;', BSID-DMBTR.
      CLEAR: VDMBTR, VSGTXT, VRECORD.
      SUBNO = SUBNO + 1.
      VSUBNO = SUBNO.
      VSGTXT = '&#37109;&#36865;&#26009;'.
      VDMBTR = BSAD-DMBTR.
      CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT
      VDMBTR INTO VRECORD SEPARATED BY ','.
      TRANSFER VRECORD TO E_FILE.
      WRITE :/ PAGENO, SUBNO,DATAKBN,ITAB_LIFNR-LIFNR,ITAB_LIFNR-NAME2,
             P_PAY_T,'&#37109;&#36865;&#26009;', BSAD-DMBTR.
      CLEAR: VDMBTR, VSGTXT, VRECORD.
      SUBNO = SUBNO + 1.
      VSUBNO = SUBNO.
      VSGTXT = '&#25391;&#36796;&#12415;&#25163;&#25968;&#26009;'.
      VDMBTR = BSEG-DMBTR.
      CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT
      VDMBTR INTO VRECORD SEPARATED BY ','.
      TRANSFER VRECORD TO E_FILE.
      CLEAR: VDMBTR, VSGTXT, VRECORD.
      WRITE :/ PAGENO,SUBNO,DATAKBN,ITAB_LIFNR-LIFNR,ITAB_LIFNR-NAME2,
            P_PAY_T,'&#25391;&#36796;&#12415;&#25163;&#25968;&#26009;',BSEG-DMBTR.
    *&#12381;&#12398;&#20182;&#12398;&#25903;&#25173;&#12356;&#12398;&#20966;&#29702;
      SUBNO = SUBNO + 1.
      VSUBNO = SUBNO.
      VSGTXT = '&#12381;&#12398;&#20182;&#12398;&#25903;&#25173;&#12356;'.
      VDMBTR = GLT0-TSL05.
      CONCATENATE VPAGENO VSUBNO VDATAKBN VCODE VNAME2 VPAYDAT VSGTXT
      VDMBTR INTO VRECORD SEPARATED BY ','.
      TRANSFER VRECORD TO E_FILE.
      WRITE :/ PAGENO,SUBNO,DATAKBN,ITAB_LIFNR-LIFNR,ITAB_LIFNR-NAME2,
            P_PAY_T, '&#12381;&#12398;&#20182;&#12398;&#25903;&#25173;&#12356;',GLT0-TSL05.
                                     glt0-tsl05.
    ULINE.
    CLEAR: VREC, VRECORD,VCODE,VNAME2,VPAYDAT,VSGTXT,VSGTXT1,VKINGAKU.
    CLEAR: VBIKKO,VBELNR,VDMBTR,VGLT0-KSLVT,VGLT0-TSL01,VGLT0-TSL02.
    CLEAR: VGLT0-TSL03,VGLT0-TSL04,VGLT0-TSL05,VKIN,VTEGA,VWK_PAY_AMOUNT.
    ENDFORM.

  • Need to read text file content and have to display it in multiline text box

    dear all,
    Need to read text file content and have to display it in multiline text box.
    actually im new to file handling. i have tried up to get_line and put_line.
    in_file := TEXT_IO.FOPEN ('D:\SAMPLE.txt', 'r');
    TEXT_IO.GET_LINE (in_file,linebuf);
    i dont know how to assign this get_line function to text item
    pls help me in this regards,

    Simply write:
    in_file := TEXT_IO.FOPEN ('D:\SAMPLE.txt', 'r');
    TEXT_IO.GET_LINE (in_file,linebuf);
    :block2.t1 := chr(10)||:block2.t1||chr(10)||linebuf;
    chr(10) --> is for new line character

  • Read lines from text file to java prog

    how can I read lines from input file to java prog ?
    I need to read from input text file, line after line
    10x !

    If you search in THIS forum with e.g. read lines from file, you will find answers like this one:
    Hi ! This is the answer for your query. This program prints as the output itself reading line by line.......
    import java.io.*;
    public class readfromfile
    public static void main(String a[])
    if you search in THIS forum, with e.g. read lines from text file
    try{
    BufferedReader br = new BufferedReader(new FileReader(new File("readfromfile.java")));
    while(br.readLine() != null)
    System.out.println(" line read :"+br.readLine());
    }catch(Exception e)
    e.printStackTrace();
    }

  • Find and edit specific line in text file?

    Hello I want to read a text file that could look in some different ways since the user choose file from a list. I then want to igonre all the lines that begin with a special character, for example %. I then want to find all the lines "words" that begin with TRY for example and put those "words" in a string or array. If there is one line that contains TRY100 and anoter line that contains TRY200 I want to find those words and display them. How do i do this?

    First you read the entire file.  Use the Read Text File.  Right-click on it and select the option to Read Lines.  The the count to read to -1 (read all).  You will now have an array of strings, one item for each line of your file.
    Now you need to play the filter game.  I recommend using FOR loops with Autoindexing tunnels.  Assuming you are using 2012 or later, have the output autoindexing tunnels use the conditional tunnel.
    Give this a try and see where you can go.  Post back with what you have tried and tell us where you are stuck.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to adjust splitted lines into one line in Text file?

    Hi Guys,
    I have a text file with 3 fields(comma separated): GLCode (Number), Desc1 (Char), Desc2(Char) and need to load it into BW.
    My Text file looks like:
    1011.00,"Mejor PC Infrastructure","This line is ok."
    1012.00,"Telephone Equipment $","This line ends in next line.   
    1)Need to change the equipment immediately.
    2)Take immediate action"
    1013.00,"V1 Computer Server Infrastructure # Equip","For purchases
    of components that make up the company's network, such as servers, hubs, routers etc."
    1014.00,"Flash Drive","Need to provide all IT Developer"
    This is how file looks like. Now I need the followings:
    1. Need to remove the space and need to adjust the splitted line into one. Say here
    line/record 2 is splitted into 3 lines and need to adjust in 1 line.
    2. In Line 5 (Record 3) data splitted into 2 lines and need to make 1 line.
    3. Need to remove bad characters.
    Could someone help me please how to proceed ?
    Regards,

    Not quite correct by my testing.  Try:
    $i=0
    Get-Content .\test.txt | ForEach {
    If ($i%2){
    ("$Keep $($_)").Trim()
    }Else{
    $keep=$_
    }$i++
    Good catch!
    Boe Prox
    Blog |
    Twitter
    PoshWSUS |
    PoshPAIG | PoshChat |
    PoshEventUI
    PowerShell Deep Dives Book

  • Appending to new line in text file

    I am trying to append text to a new line to a file. I set the append parameter to true and I try to output the new line character after I write the string to the file. However it is still appending the next string to the end of the first rather than in the line below. My code is below. Can someone please help me?
    Thanks
    public static boolean WriteToFile(String nameOfFile,
    String contents)
    FileWriter myFileWriter = null;
    try
    System.out.println("Attempting to write text to = " + nameOfFile);
    myFileWriter = new FileWriter(nameOfFile,true);
    myFileWriter.write(contents);
    myFileWriter.write('\n');
    myFileWriter.close();
    return true;
    catch (Exception e)
    System.out.println("EXCEPTION thrown ");
    return false;
    }

    I am trying to append text to a new line to a file.
    I set the append parameter to true and I try to
    o output the new line character after I write the
    string to the file. However it is still appending the
    next string to the end of the first rather than in
    the line below. My code is below. Can someone please
    help me?
    Thanks
    public static boolean WriteToFile(String nameOfFile,
    String
    String
    String contents)
    FileWriter myFileWriter = null;
    try
    System.out.println("Attempting to write
    ting to write text to = " + nameOfFile);
    myFileWriter = new
    eWriter = new FileWriter(nameOfFile,true);
    myFileWriter.write('\n');
    myFileWriter.write(contents); myFileWriter.close();
    return true;
    catch (Exception e)
    System.out.println("EXCEPTION thrown ");
    return false;
    try the change what i have made in bold

  • How can I remove a line from a file?

    how ca i remove one or more than one line from a text file?

    Open the file for input.
    Open another file for output.
    Read each input line.
    If you want to delete it, go get the next line
    Otherwise, write the line to output, and go get the
    next line.
    Close both files.

  • Identifying text file names and importing on single Excel sheet

    Hey!
    Does anybody can help me with Excel VBA macro code in order to import data from text files into single Excel spread sheet? I want to create User Form where user can select start and end date of interest and macro code will import
    bunch of text files depending on user demands...
    My text files are named: 20130619004948DataLog.txt (meaning: yyyy mm dd hh mm ss). Text file contains recordings for each 15 seconds... It would be great to omit time tail (meaning that user can only specify date). Text files for one day of interest (I have
    text files covering whole year):
    20130619004948DataLog.txt
    20130619014948DataLog.txt
    20130619024948DataLog.txt
    20130619034948DataLog.txt
    20130619044948DataLog.txt
    20130619054948DataLog.txt
    20130619064948DataLog.txt
    20130619074948DataLog.txt
    20130619084948DataLog.txt
    20130619094948DataLog.txt
    20130619104948DataLog.txt
    20130619114948DataLog.txt
    20130619124948DataLog.txt
    20130619134948DataLog.txt
    20130619144948DataLog.txt
    20130619154948DataLog.txt
    20130619164948DataLog.txt
    20130619174948DataLog.txt
    20130619184948DataLog.txt
    20130619194948DataLog.txt
    20130619204948DataLog.txt
    20130619214948DataLog.txt
    20130619224948DataLog.txt
    20130619234948DataLog.txt
    Option Explicit
    Sub SearchFiles()
    Dim file As Variant
    Dim x As Integer
    Dim myWB As Workbook
    Dim WB As Workbook
    Dim newWS As Worksheet
    Dim L As Long, t As Long, i As Long
    Dim StartDateL As String
    Dim EndDateL As String
    Dim bool As Boolean
    bool = False ' to check if other versions are present
    StartDateL = Format(Calendar1, "yyyymmdd")
    EndDateL = Format(Calendar2, "yyyymmdd")
    ' I am using Userform asking user to select the date and time range of interet,
    ' However, I want to use only the date to filter the files having the name with that particular date
    file = Dir("c:\myfolder\") ' folder with all text files
    ' I need assistance with the following part:
    '1) How to filter and select the files between StartDateL and EndDateL_
    '(including files with that dates as well)?
    While (file <> "")
    If InStr(file, StartDateL) > 0 Then 'Not sure if the statements inside parenthesis is correct
    bool = True
    GoTo Line1:
    End If
    file = Dir
    Wend
    Line1:
    If Not bool Then
    file = "c:\myfolder\20130115033100DataLog.txt" 'Just for a test that the code works as intended
    End If
    'This part for the selected text files to be loaded on a single Excel Sheet.
    Set myWB = ThisWorkbook
    Set newWS = Sheets(1)
    L = myWB.Sheets(1).Cells(Rows.Count, "A").End(xlUp).Row
    t = 1
    For x = 1 To UBound(file)
    Workbooks.OpenText Filename:=file(x), DataType:=xlDelimited, Tab:=True, Semicolon:=True, Space:=False, Comma:=False
    Set WB = ActiveWorkbook
    WB.Sheets(1).UsedRange.Copy newWS.Cells(t, 2)
    t = myWB.Sheets(1).Cells(Rows.Count, "B").End(xlUp).Row + 1
    WB.Close False
    Next
    myWB.Sheets(1).Columns(1).Delete
    Application.ScreenUpdating = False
    Rows("1:1").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    End Sub

    - Make a new Excel file
    - Open the VBA editor
    - Add a Userform
    - Place 2 text boxes and 1 command button on that form
    - Paste all code below into the code module of the form
    - Download this file:
    https://dl.dropboxusercontent.com/u/35239054/FileSearch.cls
    - In the VBA editor press CTRL-M and import that file
    - Save the Excel file in the directory that contain your text files
    - Run the form
    You can format the columns of the sheet as you like, e.g. column E:H should be a number with 5 decimal places. The top row can contain some headings. My code did not affect the formatting or the headings.
    Andreas.
    Option Explicit
    Private Sub UserForm_Initialize()
    'Just a sample
    Me.TextBox1.Value = FormatDateTime(Now, vbGeneralDate)
    Me.TextBox2.Value = FormatDateTime(Now, vbShortDate)
    End Sub
    Private Sub CommandButton1_Click()
    Dim StartDate As Date, EndDate As Date
    Dim FS As New FileSearch
    Dim R As Range
    Dim ThisFile As Variant
    Dim ThisDate As Date
    Dim Data As Variant
    Dim Count As Long
    'Be sure we have 2 dates
    If Not IsDate(Me.TextBox1.Value) Then
    Me.TextBox1.SetFocus
    MsgBox "No start date"
    Exit Sub
    End If
    If Not IsDate(Me.TextBox2.Value) Then
    Me.TextBox2.SetFocus
    MsgBox "No end date"
    Exit Sub
    End If
    'Convert to real dates
    StartDate = CDate(Me.TextBox1.Value)
    EndDate = CDate(Me.TextBox2.Value)
    'Time part given?
    If Fix(EndDate) = EndDate Then
    'No include all files for this day
    EndDate = EndDate + TimeSerial(23, 59, 59)
    End If
    'Correct order?
    If StartDate > EndDate Then
    ThisDate = EndDate
    EndDate = StartDate
    StartDate = ThisDate
    End If
    With FS
    'Same path as our file
    .LookIn = ThisWorkbook.Path
    .FileName = "*DataLog.txt"
    'Search all files sort by file name
    If .Execute(msoSortByFileName, msoSortOrderAscending) = 0 Then
    MsgBox "No data files found in " & .LookIn
    Exit Sub
    End If
    'Clear previous data
    Set R = Range("A2").CurrentRegion
    If R.Row < 2 Then Set R = R.Offset(1)
    R.ClearContents
    'Show the user that we are working
    Application.Cursor = xlWait
    DoEvents
    For Each ThisFile In .FoundFiles
    'Get the date from the file name
    ThisDate = Filename2Date(ThisFile)
    'Between our dates?
    If (ThisDate >= StartDate) And (ThisDate <= EndDate) Then
    'Import at the end of the data
    Set R = Range("A" & Rows.Count).End(xlUp).Offset(1)
    Data = ReadCSV(ThisFile)
    R.Resize(UBound(Data) + 1, UBound(Data, 2) + 1) = Data
    Count = Count + 1
    End If
    Next
    End With
    'Done
    Application.Cursor = xlDefault
    If Count = 0 Then
    MsgBox "No files match your dates"
    Else
    MsgBox Count & " files imported"
    'Hide the form
    Me.Hide
    End If
    End Sub
    Private Function Filename2Date(ByVal Fullname As String) As Date
    'Convert e.g "C:\20130601142648DataLog.txt" to the date "01.06.2013 14:26:48"
    Dim i As Long, j As Long
    i = InStrRev(Fullname, "\")
    If i > 0 Then Fullname = Mid(Fullname, i + 1)
    Fullname = JustNumbers(Fullname)
    If Len(Fullname) <> 14 Then Exit Function
    Filename2Date = _
    DateSerial(Mid(Fullname, 1, 4), Mid(Fullname, 5, 2), Mid(Fullname, 7, 2)) + _
    TimeSerial(Mid(Fullname, 9, 2), Mid(Fullname, 11, 2), Mid(Fullname, 13, 2))
    End Function
    Private Function JustNumbers(ByVal What As String) As String
    'Return only numbers from What (by Rick Rothstein)
    Dim i As Long, j As Long, Digit As String
    For i = 1 To Len(What)
    Digit = Mid$(What, i, 1)
    If Digit Like "#" Then
    j = j + 1
    Mid$(What, j, 1) = Digit
    End If
    Next
    JustNumbers = Left$(What, j)
    End Function
    Private Function ReadCSV(ByVal Fullname As String) As Variant
    'Read a CSV file into an array
    Const LDelim = vbCrLf 'Line delimiter
    Const FDelim = ";" 'Field delimiter
    Dim hFile As Integer
    Dim Buffer As String
    Dim Lines, Line, Data
    Dim i As Long, j As Long
    'Be sure the file exists
    If Dir(Fullname) = "" Then Exit Function
    'Open and read all data
    hFile = FreeFile
    Open Fullname For Binary Access Read As #hFile
    Buffer = Space(LOF(hFile))
    Get #hFile, , Buffer
    Close #hFile
    'Split into lines
    Lines = Split(Buffer, LDelim)
    'Split the first line and prepare the output
    'Note: I assume that all lines have the same number of fields
    Line = Split(Lines(0), FDelim)
    ReDim Data(0 To UBound(Lines), 0 To UBound(Line))
    For i = 0 To UBound(Lines)
    Line = Split(Lines(i), FDelim)
    For j = 0 To UBound(Line)
    'Parse the fields
    If IsDate(Line(j)) Then
    Data(i, j) = CDate(Line(j))
    ElseIf IsNumeric(Line(j)) Then
    Data(i, j) = CDbl(Line(j))
    Else
    Data(i, j) = Line(j)
    End If
    Next
    Next
    ReadCSV = Data
    End Function

Maybe you are looking for

  • WebLogic Error : Registered more than one instance with the same objectName

    HI there, I'm facing a big problem. I have two environments installed on the same physical machine. I have ALSB and WLI servers running out there. Environment 1 - WLI port running at 7011 domain name : stp_wli_domain and ALSB port running at 8011 dom

  • BAPI BAPI_ADDRESSORG_SAVEREPLICA

    Hi Friends, can we use  FM BAPI BAPI_ADDRESSORG_SAVEREPLICA for Adderss details  and also Mobile Tel no, FAX_NUMBER, Email Address . contact persons in vendor masetr update. pls help anyone to solve this issue. Regards, Sreenu.

  • Message the older version of apple software can not be removed

    Hi, I have bought a new iphone4s and when I tried to install in to my itunes it told me I needed an updated version of itunes. So I downloaded the latest and get a message " The older version of Apple Software Update cannot be removed" and then the i

  • Spell Check in "Pages" not working

    I read a few posts, made sure my language was set (not void of one)... still doesn't work!

  • Is there a way to reset ZipInputStream?

    Hi, My api receives as an input a ZipInputStream, and processes certain files in the stream. The algorithm that this api implements needs to scan the files back and forth multiple times. So I would either read all the files into the JVM and do the sc