f



wrong file size when saving an sqlite blob to a file using tcl

Hello Group,
I hope you can give me some pointers in solving the next problem:

Using a tcl script, I read an MSAccess mdb file into a tcl variable (using 
[fconfigure $f -translation binary] and [read]).
Then I inserted the data in an sqlite blob field. (using an sql insert 
statement and tdbc::sqlite3).

I retrieved the mdb back to the file system using two methods:
(1) saving the blob using an option in SQLlite Manager 
(http://code.google.com/p/sqlite-manager/)
(2) using tcl:
       set outfh [open C:/testmdb.mdb w+]
       fconfigure $outfh -translation binary

       $db_name foreach -as lists -- i {
            SELECT distinct data from data where HASHCHKSUM=$datahash
         } {
             foreach {data} $i {
                # verify
                set hash [mkhash $data]
                if {$hash ne $datahash} {
                    puts "error! $hash ne $datahash"
                } {
                    puts $outfh $data
                }
             }
           }
       # clean up
       flush $outfh
       close $outfh
       $db_name close
  }

Both methods result in files with differen file sizes: Method 1 gives 
exactly the same size as the original mdb file, the tcl script gives 1 byte 
more....
Both files do open in Ms-Access, but I would really like to know the 
difference and how to get rid of the extra byte.
Especially so, since I do not want to write a complete mdb file into the 
sqlite database, but rather want to split it in blocks of data and in that 
case the extra byte could cause problems.
Thanks,
Harm





0
Harm
1/5/2010 1:18:01 PM
comp.lang.tcl 23429 articles. 2 followers. Post Follow

4 Replies
872 Views

Similar Articles

[PageSpeed] 10

On Jan 5, 2:18=A0pm, "Harm Olthof" <geenspam@invalid> wrote:
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 puts $outfh $data
>
> ...the tcl script gives 1 byte more....

I'd risk the extra byte is \n ...
If you don't want it, just ask Tcl not to put it ;-)

   puts -nonewline $outfh $data

-Alex
0
Alexandre
1/5/2010 1:25:48 PM
Hello Alexandre,
That's it! Thanks!

I never realized that [puts] still appends a \n after [fconfigure 
$f -translation binary].
I must have made this error numerous times the last 15 years or so and only 
now I ran into its consequences.
well....

Harm Olthof

"Alexandre Ferrieux" <alexandre.ferrieux@gmail.com> wrote in message 
news:33642742-939b-4186-ab67-e2a8076a8df3@e27g2000yqd.googlegroups.com...
On Jan 5, 2:18 pm, "Harm Olthof" <geenspam@invalid> wrote:
>
> puts $outfh $data
>
> ...the tcl script gives 1 byte more....

I'd risk the extra byte is \n ...
If you don't want it, just ask Tcl not to put it ;-)

   puts -nonewline $outfh $data

-Alex 


0
Harm
1/5/2010 1:56:19 PM
Harm Olthof wrote:
> Hello Alexandre,
> That's it! Thanks!
> 
> I never realized that [puts] still appends a \n after [fconfigure 
> $f -translation binary].
> I must have made this error numerous times the last 15 years or so and only 
> now I ran into its consequences.
> well....
> 
> Harm Olthof
> 
> "Alexandre Ferrieux" <alexandre.ferrieux@gmail.com> wrote in message 
> news:33642742-939b-4186-ab67-e2a8076a8df3@e27g2000yqd.googlegroups.com...
> On Jan 5, 2:18 pm, "Harm Olthof" <geenspam@invalid> wrote:
> 
>>puts $outfh $data
>>
>>...the tcl script gives 1 byte more....
> 
> 
> I'd risk the extra byte is \n ...
> If you don't want it, just ask Tcl not to put it ;-)
> 
>    puts -nonewline $outfh $data

Well, the difference lies in the final \n, doesn't it?
The "records" are separated by \n in both cases ?

uwe
0
Uwe
1/5/2010 2:32:07 PM
"Uwe Klein" <uwe_klein_habertwedt@t-online.de> wrote in message 
news:84vb17-03u.ln1@klein-habertwedt.de...
> Harm Olthof wrote:
>> Hello Alexandre,
>> That's it! Thanks!
>>
>> I never realized that [puts] still appends a \n after [fconfigure 
>> $f -translation binary].
>> I must have made this error numerous times the last 15 years or so and 
>> only now I ran into its consequences.
>> well....
>>
>> Harm Olthof
>>
>> "Alexandre Ferrieux" <alexandre.ferrieux@gmail.com> wrote in message 
>> news:33642742-939b-4186-ab67-e2a8076a8df3@e27g2000yqd.googlegroups.com...
>> On Jan 5, 2:18 pm, "Harm Olthof" <geenspam@invalid> wrote:
>>
>>>puts $outfh $data
>>>
>>>...the tcl script gives 1 byte more....
>>
>>
>> I'd risk the extra byte is \n ...
>> If you don't want it, just ask Tcl not to put it ;-)
>>
>>    puts -nonewline $outfh $data
>
> Well, the difference lies in the final \n, doesn't it?
> The "records" are separated by \n in both cases ?
>
> uwe

Right! The amzing thing for me was that Access still could open the file. In 
the block version it only complained that "others" were editing the files...
Thanks,
Harm 


0
Harm
1/6/2010 8:18:24 PM
Reply:

Similar Artilces:

Sourcing a TCL file from within a tcl file
I am a newbie which I am sure I don't need to state :) I am trying to create a variable with a TCL file that will source another tcl file when I type the variable name something like this if I enter A through my keyboard then source a.tcl Can someone show me how to do this thanks guy On Dec 10, 1:15=A0pm, guy <gcoletta2...@gmail.com> wrote: > I am a newbie which I am sure I don't need to state :) > > I am trying to create a variable with a TCL file that will source > another tcl file when I type the variable name > > something like this > > if I e...

Tcl file from .txt file
Hi, I have a excel file. I need to change the excel file in to tcl file. I did = change the excel file in to txt file. but unable to change the txt file in = to tcl file. let me know any idea to change the txt file in to tcl file or = directly from the excel file in to tcl file.=20 your help is much more appreciated. thank you. On 11/14/14, 1:30 PM, yenilsuwal@gmail.com wrote: > Hi, > > I have a excel file. I need to change the excel file in to tcl file. I did change the excel file in to txt file. but unable to change the txt file in to tcl file. let me know any idea to c...

How to capture the output from TCL prompt and save it to a file on Linux file system.
Hello All, I login to TCL prompt and run a simple query which lists few rows. I want to capture those rows and save it to a file on file system. I am working on a Sun Solaris ver. 5.9. Here is the sample query that i run from TCL prompt: >SELECT DISTINCT CATEGORY FROM DS_JOBS; And the Resultant set looks like this: Category............ ABC\ACEIQ\JOBS\C UST_SPCLTY ABC\ACEIQ\JOBS\C UST_SPC SSHIP\SEQ PLIC\CNTRL Any advise is greatly appreciated. Thanks Vini On Mar 22, 7:26=A0pm, Vini <vinay.renukun...@gmail.com> wrote: > Hello All, > > I login to TCL prompt and run a si...

upload ".zip" file [transfer files using tcl script]
I want to upload .zip file from my windows box to unix box i mean i want to transfer files using tcl script. Thanks in advance file transfer protocol - ftp - is the protocol of choice. A wiki page "Simple ftp uploader" shows an example using the ftp package. May I suggest to access the wiki page per http://taipu.de/ida.htm, to get pointed to the wiki page http://wiki.tcl.tk/1502 with minimal typing effort? best regards, Roland Frank senthilvaishnavi schrieb: > I want to upload .zip file from my windows box to unix box i mean i > want to transfer files using...

saving files using a variable file name
I would like to have a loop that saves a series of files of different names but it seems like I can't use a variable string as my file name when using save. For example: >> name = 'testname.mat' >> save name saves a file named <name.mat> when I'd like a file named <testname.mat>. Is there a way to do what I am looking for? Thanks. Kasey Kasey Horton wrote: > > > I would like to have a loop that saves a series of files of > different > names but it seems like I can't use a variable string as my file > name > when using save. ...

How to do data parsing from library file to tcl file?
Hi I have to copy some data from a library file and use it in a tcl command. Can some one tell me how to do that? I am new to tcl so finding it hard. On 07/01/2013 02:53 PM, Paromita Banerjee wrote: > Hi I have to copy some data from a library file and use it in a tcl command. Can some one tell me how to do that? I am new to tcl so finding it hard. Please explain what the phrase "library file" means to you. An example might be helpful. -- | Don Porter Applied and Computational Mathematics Division | | donald.porter@nist.gov Information Technol...

IE save the pdf file in wrong file
Hi, I've had the following URL that generated by the javascript. It works as "down a pdf file" https://10.10.10.167/portal/servlet/project.SaveFile?PageUrl=ReportManager&FileName=tmp36237.pdf I expected that the pdf filename should be tmp36237.pdf, however if I opened it in IE, it saves the file with a filename project.pdf. If I am using firefox, it saves the correct filename. I wonder if anybody can help me on this issue. best regards, Kit --- My code ---- I've had the correct filename right from alert() though... function download_pdfFile() { alert ("This ...

Mex FIles, TCL Files, amd Simulink.
Hi, Everyone. I'm new at Matlab & Simulink, and although I've been making pretty good progress, I find myself rather stuck. I am writing a bit of C code to determine the time between too events: When event one happens, I record the current time in the state vactor, and when event 2 happends, I record the divverence in the state vator. My output is simply the difference. I have been trying to use the S-Function builder, but it doesn't seem to like ssGetT(S), where S is the SimStruct thingy - I don't know hot to get it passed into the Builder routine. So what I ha...

File Size
Not a terrbily accomplished C coder here. I have a small ANSI C app that at some point needs to know the number of bytes in a file. I've seen a few suggestions along the lines of: fseek(fIn, 0, SEEK_END); fSize = ftell(fIn); Which worked great until now. We have now come across a situation where the file is huge (one specific example is 4,499,692,752 bytes). Even if fSize is declared as "long long", which is big enough to handle that value, it is not geting the correct value. So that tells me that either fseek can't get that far into the file or ftell can'...

Using TCL files in Python ?
I am reasonably new to programming in Python. [Using LINUX] Up until now I have been using GUI widgets supplied by 'Tkinter' but starting to realise that Tkinter have limited widgets. I have been given the lead that I should look at other sources for GUI widgets - namely TCL. I have just done a search for 'tcl' files on my 'Fedora 3' installation and find I have available: Tix8.1 Tcl8.4 Tk8.4 I have never used TCL code under Python so I assume I can use widgets from any of these providers ? Where is a good resource I can use to help understand how to use TCL...

How to read a file using TCL
Hi, I am a new bee to TCL. I want to write a script that opens the file and reads it and prints to screen. I have tried the below. But doesn't works. set INFILE [open "temp" a+] set data [read $INFILE] set data [split $data "\n"] foreach line $data { puts $line } -Regards Swaroop Kumar Tata On 14 Mai, 10:39, Swaroop <swaroop.t...@gmail.com> wrote: > Hi, > I am a new bee to TCL. I want to write a script that opens the > file and reads it and prints to screen. I have tried the below. But > doesn't works. > > set INF...

How to convert the file which is saved using idl to fits file
Hi, I have some 22 fits files, after doing data reduction operation to all the 22 files, I have saved it as file.sav. Now I need to convert the file.sav to 22 individual fits files. Please give me some tips. regards sid On Apr 30, 2:58=A0pm, sid <gunvicsi...@gmail.com> wrote: > Hi, > =A0 =A0 I have some 22 fits files, after doing data reduction operation t= o > all the 22 files, I have saved it as file.sav. Now I need to convert > the file.sav to 22 individual fits files. Please give me some tips. > regards You asked a similar question last week about c...

How to write tcl generated xml file into a new file
Hi, I have generated a xml file using xmlgen. After running the tcl script the ouput is displayed on the terminal . I want to take the terminal output into a xml file. Any Suggestion ???/ Thanks Ranjan On Nov 25, 12:46=A0pm, gyana behera <ranjan....@gmail.com> wrote: > Hi, > > I have generated a xml file using xmlgen. > After running the tcl script the ouput is displayed on the terminal . > I want to take the terminal output into a xml file. > > Any Suggestion ???/ > > Thanks > Ranjan Either redirect the output of the script to the xml-file. (xmlgen &g...

[Tcl] file copy does not "touch" file. Why?
In a situation, when both source and destination files exist, file copy (with -force of course) does not update the last modification time of the destination file. This "feature" has a strong impact on cooperation with 'make'. Is that really intended? I have to do 'touch' externally to make it correct. The external "cp" command on unix does touch the destination file. -- // _ ___ Michal "Sektor" Malecki <sektor(whirl)kis.p.lodz.pl> \\ L_ |/ `| /^\ ,() <ethourhs(O)gmail.com> // \_ |\ \/ \_/ /\ C++...

Web resources about - wrong file size when saving an sqlite blob to a file using tcl - comp.lang.tcl

Saving - Wikipedia, the free encyclopedia
Saving also includes reducing expenditures, such as recurring costs . In terms of personal finance , saving specifies low-risk preservation of ...

Saving extra super raises risk of financial hardship
Unless you are close to retirement, diverting money into super can and often does result in financial problems before you can access it.

Principal killed after saving children
A primary school principal in the US is struck by a bus after pushing students out of harm's way.

'They just loved her': heroic Indiana school principal dies saving children from bus
When the school bus lurched forward, Susan Jordan followed her instincts. They were the same instincts that had guided her for 22 years as the ...

Microsoft’s Edge browser is apparently saving your private browsing data
As if Microsoft doesn't have enough explaining to do when it comes to security on Windows 10 , a recent investigation of Edge has revealed that ...

Admit It: You've Been Watching Crap TV and It's Saving Your Life Right Now
Have you been finding yourself watching junk television like a kid with a freshly filled Halloween pumpkin? You are not alone. I've been watching ...

Actress-filmmaker duo on "The Wait," saving sex for marriage - Videos - CBS News
... outlook in "Jumping the Broom." It was on that set where she first worked with her filmmaker husband, DeVon Franklin. They believe saving sex ...

Are you saving enough for retirement?
Putting money away early adds a powerful tool to your retirement savings arsenal, but that's not all you can do.

Northwestern MutualVoice: 6 Retirement Savings Tips For Generation X
By Lisa Wirthman The members of Generation X are the country’s unhappy middle children. Stuck between Boomers and Millennials, these adults between ...

Boeing’s fuel-saving 737 MAX jet gets a ‘wow’ review after first flight
Boeing’s newest breed of airplane, the fuel-efficient 737 MAX, took to the air for the first time today – and the first pilots to fly it had ...

Resources last updated: 2/3/2016 8:22:24 PM