OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

what does ^@ sign in .txt file suggest

  • Thread starter Thread starter Daniel
  • Start date Start date
D

Daniel

Guest
I was concurrently manipulating a txt file (some r/w operation)with multiple processes. and I saw traces of special signs as ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ spreading across some lines now and then. What does this suggest? And under what circumstances will these symbols appear. Does it mean some binary contents were written in to, by mistake, where it should be text?

UPDATE I read through the documentation. Some suggest it's due to newline issue on linux/windows platform, while others suggest it's because of big endian/small endian in a networked environment. The fact is I was running multiple processes in a networked filesystem and manipulate one common txt file. So I guess the encoding format might be the major reason. Anyone who can suggest how to avoid this issue? I don't want to edit files(like manually doing text substitution). A clean way of producing the right file without any null characters are preferred.

UPDATE2 This is the python pseudo code that implements my project. the fcntl.lockf thing is to lock the common manipulated file across multiple machines that run multiple process on it.

Code:
 while(manipulatedfile size is not 0):
           open(manipulatedfile, 'r+') as fh:
           fcntl.lockf(fh, fcntl.LOCK_EX)
           all_lines = fh.readlines()
           listing=all_lines[0:50] #get the first 50 lines
           rest_lines = all_lines[50:] # get remaining lines
           fh.seek(0)
           fh.truncate()
           fh.writelines(rest_lines) # write remaining lines back to file
           fcntl.lockf(fh, fcntl.LOCK_UN)
           listing = map(lambda s:s.strip(), listing)
           do_sth(listing)

Thanks
<p>I was concurrently manipulating a txt file (some r/w operation)with multiple processes. and I saw traces of special signs as ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ spreading across some lines now and then. What does this suggest? And under what circumstances will these symbols appear. Does it mean some binary contents were written in to, by mistake, where it should be text? </p>

<p><strong>UPDATE</strong>
I read through the documentation. Some suggest it's due to newline issue on linux/windows platform, while others suggest it's because of big endian/small endian in a networked environment. The fact is I was running multiple processes in a networked filesystem and manipulate one common txt file. So I guess the encoding format might be the major reason. Anyone who can suggest how to avoid this issue? I don't want to edit files(like manually doing text substitution). A clean way of producing the right file without any null characters are preferred. </p>

<p><strong>UPDATE2</strong>
This is the python pseudo code that implements my project. the fcntl.lockf thing is to lock the common manipulated file across multiple machines that run multiple process on it. </p>

<pre><code> while(manipulatedfile size is not 0):
open(manipulatedfile, 'r+') as fh:
fcntl.lockf(fh, fcntl.LOCK_EX)
all_lines = fh.readlines()
listing=all_lines[0:50] #get the first 50 lines
rest_lines = all_lines[50:] # get remaining lines
fh.seek(0)
fh.truncate()
fh.writelines(rest_lines) # write remaining lines back to file
fcntl.lockf(fh, fcntl.LOCK_UN)
listing = map(lambda s:s.strip(), listing)
do_sth(listing)
</code></pre>

<p><strong>Thanks</strong></p>
 
Top