Split after the occurence number - Issue

I have an SQL query file to split by 1000 lines but unfortunately when I choose “Split after the occurence number” there is one bug.
Here are the options that I’ve used :
I want to split after the nth occurence of a specified pattern -> Split after the occurence number -> 1000 -> 0x0D0x0A
Piece Name Mask : test_{oru}.sql
Do not add GSplit tags to piece files -> Insert additional header to pieces -> Copy all the data prior to the first occurence or line

At each files (starting from the second) one line is missing.
But when I choose “Split before the occurence number” all works perfectly (cpatternhowsplit_ItemIndex set to 1).

Big file content :
Header
Line 0001

Line 1000
Line 1001
Line 1002

Line 2000
Line 2001

Line xxxx

->
File 1 is ok :
Header
Line 0001

Line 1000

File 2 is bad :
Header
Line 1002

Line 2001

Should be :
Header
Line 1001

Line 2000

Also, is it possible to add an option to delete the last character or a pattern at the end of each file splited :?:
For my case, I need to remove the last “,” (comma) from the SQL command to avoid an error.
I think, it could be useful for other cases :!:

Just in case here is the file config :

<?xml version="1.0" encoding="iso-8859-1"?>
<GSplitProfile>
  <Settings>
    <FormVersion>0</FormVersion>
    <CustomSizesCount>0</CustomSizesCount>
    <GSplitVersion>30010</GSplitVersion>
    <BlockedPieces>TRUE</BlockedPieces>
    <fich_Text>C:\test\big.sql</fich_Text>
    <destdir_Text>C:\test\</destdir_Text>
    <cdecide_ItemIndex>3</cdecide_ItemIndex>
    <tsize_Text>531</tsize_Text>
    <cselunit_ItemIndex>1</cselunit_ItemIndex>
    <nomp_Text>test_{oru}.sql</nomp_Text>
    <cpriority_ItemIndex>2</cpriority_ItemIndex>
    <csfufonc_Checked>FALSE</csfufonc_Checked>
    <cchangenom_Checked>FALSE</cchangenom_Checked>
    <tnomsfu_Text/>
    <cmerge_Checked>FALSE</cmerge_Checked>
    <ico_Text/>
    <cnoaccount_Checked>TRUE</cnoaccount_Checked>
    <memwelc_Lines>
      <Count>9</Count>
      <Item0>Bienvenue dans ce programme. Il vous permet de restaurer le fichier découpé suivant :</Item0>
      <Item1/>
      <Item2> {filename}</Item2>
      <Item3> {desc}</Item3>
      <Item4> Taille : {size} ; {fullsize} octet(s).</Item4>
      <Item5> {piececount} fichiers pièce sont requis.</Item5>
      <Item6/>
      <Item7>Choisissez où vous souhaitez placer le fichier restauré</Item7>
      <Item8>et cliquez sur Unifier pour continuer.</Item8>
    </memwelc_Lines>
    <sprompt_Text/>
    <eprompt_Text/>
    <tabout_Text>Ce fichier a été découpé avec GSplit gratuit et disponible à www.gdgsoft.com</tabout_Text>
    <cecd_Checked>FALSE</cecd_Checked>
    <rep_ItemIndex>3</rep_ItemIndex>
    <tcustfold_Text/>
    <cover_Checked>TRUE</cover_Checked>
    <copen_Checked>FALSE</copen_Checked>
    <cwaitforend_Checked>FALSE</cwaitforend_Checked>
    <cdelete_Checked>FALSE</cdelete_Checked>
    <param_Text/>
    <cautof_Checked>FALSE</cautof_Checked>
    <cautoexec_Checked>FALSE</cautoexec_Checked>
    <csilent_Checked>FALSE</csilent_Checked>
    <header_Text/>
    <tlang_Text>C:\Program Files (x86)\GSplit\Languages\English.gsl</tlang_Text>
    <texec_Text/>
    <tpattern_Text>0x0D0x0A</tpattern_Text>
    <valoccur_Value>00000000000000FA0840</valoccur_Value>
    <cpatternhowsplit_ItemIndex>0</cpatternhowsplit_ItemIndex>
    <cnoheader_Checked>TRUE</cnoheader_Checked>
    <firstdisk_Value>00000000000000000000</firstdisk_Value>
    <resspace_Value>00000000000000000000</resspace_Value>
    <tuniqid_Text>{663CE888-11BD-4B77-8C10-0BA82AF658AD}</tuniqid_Text>
    <tdesc_Text/>
    <GTit_Text>Archive GSplit</GTit_Text>
    <createur_Text>GSplit 3.0.1</createur_Text>
    <caddheader_Checked>TRUE</caddheader_Checked>
    <cheaderfirstoccur_Checked>TRUE</cheaderfirstoccur_Checked>
    <cheaderinsertline_Checked>FALSE</cheaderinsertline_Checked>
    <taddheadpattern_Text/>
    <cdelfolder_Checked>FALSE</cdelfolder_Checked>
    <tbufsize_Value>00000000000000800540</tbufsize_Value>
  </Settings>
</GSplitProfile>  

Thanks. I’ll study the problem.

Ha you just solved my problem,

I have the same, already figured out that splitting after the xxxth occurrence of 0x0D0x0A.

0x0D0x0A will not be included at the end of the first copied line.

So the first line of the parts are the copied line from part1 and the first line of part-XX.

I use it to split large csv files, no interest of joining again.

Never tried the option to split before the occurrence but just opened the parts with notepad++ and included the cr lf manualy.

For me no big deal to split before or after, however it’s an error.

Bas

I’m also encountering this problem on a project I’m working on. (no actual data missing, just that the extra inserted header line isn’t terminated properly)

Perhaps having an option to allow “include pattern” when using the “copy all the data prior to the first occurrence or line” will allow it to work for us, without breaking existing behaviour for any use case where it is desirable.