[ic] Lost most items in my products.txt after export via UI!

Dan Browning interchange-users@lists.akopia.com
Tue Jul 31 16:11:01 2001


At 09:45 PM 7/31/2001 +0200, you wrote:
>Ed LaFrance wrote:
> >
> > At 03:31 PM 07/31/2001 +0200, you wrote:
> > >Hi List,
> > >
> > >i try to find out the cause of the wrong products.txt after using the
> > >export in UI.
> > >I've for example 1000 products and I get 15 products after export (UI)
> > >suddenly!
> > >Why? How can I find the wrong products, which makes my products.txt mad?
> > >Any tips, helps and suggestions are very welcome.
> > >
> > >Thanks!
> > >
> > >Joachim
> >
> > It sounds like you are using the default database (db, gdbm) and you
> > exported to the default file name, which is the source text file name for
> > the table.  Given that, something broke in the process and truncated your
> > file, which was then imported back into the products binary file on the
> > next access.  Do you have a backup?  Use it.  When exporting binary tables,
> > supply an alternate name for the text file (i.e.: products.exp) so that
> > your database is not jeopardized.
>
>Thanks for your fast reaction.
>I've a backup and I've exported the database into another file and get
>the same result. :-(
>There are different behavior between the normal shop and  the UI. If i
>search for "e", the shop find 1330 products. This is my whole database.
>If i click the "items" in my UI, UI can only found 15 products. If i
>search for "Beer", the shop can list all items with "Beer". If I search
>for "Beer" in UI, UI can't found that items. Very strange!
>
>What ist the cause?
>Maybe, there are some Codes from Windows via Copy & Paste? How can I
>find this Codes?
>
>Thanks!
>
>Joachim

I'm not sure if Windows carriage returns are your problem (\r\n), but I can 
tell you how to search for and remove them:

od -a products.txt | grep <cr>

If anything shows up on your screen, you have windows line endings.  You 
can remove them pretty easily in a variety of ways:

1. Use tr

$tr -d "\r" < oldfile > newfile

2. Perl oneliner:

$perl -pi -e 's/\r//g'

3. vi:

Open the file in vi.
Press ESC twice to be certain that you are in command mode.
Enter :.,$s/^V^M//g
Press return.
Note: ^V is Ctrl-V and ^M is Ctrl-M
You can also put '.,$s/^V^M//g' into a file called 2unix.vi, and run:
vi -s 2unix.vi [files]

HTH,

Dan Browning, Cyclone Computer Systems, danb@cyclonecomputers.com