readdlm() pound sign at beginning of string is not read

70 views
Skip to first unread message

Anonymous

unread,
Jun 25, 2016, 4:41:55 PM6/25/16
to julia-users
Let's say I have a file of the form

1    #hello
2    hello

Where the space between the number and the ascii string is intended to be a tab, then I run

my_file = readdlm(file, '\t')

this reads in the first line as "".  Is this the desired functionality?  It works fine with other characters like @ or &.

Dan

unread,
Jun 26, 2016, 8:39:03 AM6/26/16
to julia-users
Yes, this is the intended functionality because # is used a character which starts a comment in the file which is not parsed. The simplest way around this is to disble comments using the named parameter `comments` like this:
    readdlm(file,'\t',comments=false)

You can also change the character used for comments to something else, using named parameter `comment_char`.

The Julia documentation about `readdlm` should explain this (http://docs.julialang.org/en/release-0.4/stdlib/io-network/#Base.readdlm).

Perhaps if the fields are quoted, the comment character does not have effect, but haven't checked this.

Anonymous

unread,
Jun 26, 2016, 5:46:11 PM6/26/16
to julia-users
oh ok, that makes sense, thanks!
Reply all
Reply to author
Forward
0 new messages