# HDFql strange characters randomly from select command

**URL:** <https://forum.hdfgroup.org/t/hdfql-strange-characters-randomly-from-select-command/6561>\
**Category:** HDFql\
**Created:** [January 13, 2020, 11:21pm UTC](https://forum.hdfgroup.org/t/hdfql-strange-characters-randomly-from-select-command/6561 "2020-01-13T23:21:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel.meier](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/d/e47774/32.png) [@daniel.meier](https://forum.hdfgroup.org/u/daniel.meier)\
**Post date:** [January 13, 2020, 11:21pm UTC](https://forum.hdfgroup.org/t/hdfql-strange-characters-randomly-from-select-command/6561/1 "2020-01-13T23:21:59Z")

</div>

Hi, new to HDF, and I found HDFql and got setup on that with the C# wrapper on Visual Studio 2013.

I just need to read some data from an existing HDF5 file and write some data values (repeatedly). I can open the file with HDFView and see the structure and types and data just fine.

The particular dataset I need to read has just a single string of length 68. It should look like this:  
“169.254.168.81~Pyrocam\_III\_HR~2020579~Spiricon.Source.Pyrocam.IV.dll”

When I execute a SELECT command and then use the (sub)cursor to walk through the char array and concatenate the string, I sometimes get the correct string, but sometimes I get something like this:  
“169.254.168.81~Pyrocam\_III\_HR~wµÈë©øã¡V2020579~Spiricon.Source.Pyrocam.IV.dll”

And sometimes it is really bad:  
“169æœÇ.2íÃr\t5æœÇ4.168.8èœå1~eœppÝpäÊ\r6NP\b\byrÿÿÿøeœöÊ6”UocaÊ6mèœè\_IÊ&6I‰ËIéœî\_Ðp!\aHR~2Ê60„20Ê:6ÄçœØÊ965ëÃrøeœÞÊ76I79~SpÊX6„\viÊV6ric„úogæ”ëpÞßì™\fn.Soeœ– urce„ü.PyÊN6rÊd6ocÊr6ø\fa„ým.IV.dl„ûl”

One other odd one I got was this (just note the extra “DFql” on the end):  
“169.254.168.81~Pyrocam\_III\_HR~2020579~Spiricon.Source.Pyrocam.IV.dllDFql”

Each time I run the same code on the same file, I get a different result. I also used HDFql.SubcursorGetCount(), and it returns 68 every time, regardless of the extra junk. I ruled out my parsing of the char array by doing it a few times in a row and comparing the results, which were always identical.(good or bad) Repeating the execution of the SELECT command, however, gives different results for each.

My command isn’t complex, just HDFql.Execute(“SELECT FROM …”)  
After that I set the cursor to first and subcursor to first, and loop through the characters, moving the subcursor to next, until I hit a null.  
Otherwise just use and close the file at the beginning and end.

Any ideas what could be causing these strange characters, and why is it randomly good or bad? And what to do about it?

Thank you.

---

<div class="post-metadata">

**Author:** ![contact](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/contact/32/1067_2.png) [@contact](https://forum.hdfgroup.org/u/contact)\
**Post date:** [January 13, 2020, 11:47pm UTC](https://forum.hdfgroup.org/t/hdfql-strange-characters-randomly-from-select-command/6561/2 "2020-01-13T23:47:24Z")

</div>

Hi Daniel,

Thanks for reporting this.

Would it be possible to send the HDF5 file (or eventually have it available in the cloud for download), as well as the HDFql C# code that reads that particular dataset? With this info, we will be able to better debug the issue you are facing.

Thanks!

---

<div class="post-metadata">

**Author:** ![daniel.meier](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/d/e47774/32.png) [@daniel.meier](https://forum.hdfgroup.org/u/daniel.meier)\
**Post date:** [January 14, 2020, 5:36am UTC](https://forum.hdfgroup.org/t/hdfql-strange-characters-randomly-from-select-command/6561/3 "2020-01-14T05:36:33Z")

</div>

Apparently new users aren’t allowed to upload. Here’s cloud links:

> **[Private file](https://www84.zippyshare.com/v/RNN5nJrW/file.html)**
>
> Zippyshare.com - Free File Hosting

  

> **[Private file](https://www84.zippyshare.com/v/Mfk37acf/file.html)**
>
> Zippyshare.com - Free File Hosting

  
Please let me know if these don’t work, haven’t used ZippyShare before.

I copied the essential code into a .txt file (easiest way to remove proprietary information). I was using VS2013 Update 5, C# .NET 4.5, and I had compiled the three wrapper .cs files provided by HDFql into a .dll and referenced that in my project. Hopefully that should be sufficient to recreate it.

Thanks.

---

<div class="post-metadata">

**Author:** ![contact](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/contact/32/1067_2.png) [@contact](https://forum.hdfgroup.org/u/contact)\
**Post date:** [January 14, 2020, 9:16am UTC](https://forum.hdfgroup.org/t/hdfql-strange-characters-randomly-from-select-command/6561/4 "2020-01-14T09:16:50Z")

</div>

Thanks for sharing these files @daniel.meier!

It seems that there is an issue with method `HDFql.SubcursorGetChar()`. As a workaround, please use method `HDFql.SubcursorGetUnsignedTinyInt()` until we fix this.

To have your C# program working correctly, method `GetHDFqlString()` should look like the following:

```
private static string GetHDFqlString()
{
	string result = string.Empty;

	HDFql.CursorFirst();
	while (HDFql.SubcursorNext() == HDFql.Success)
	{
		result += (char) HDFql.SubcursorGetUnsignedTinyInt();
	}

	return result;
} 

```

In addition, be aware that concatenating an immutable string the way you do in `GetHDFqlString()` may lead to poor performance. Better to use C# `StringBuilder` for that purpose.

---

<div class="post-metadata">

**Author:** ![daniel.meier](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/d/e47774/32.png) [@daniel.meier](https://forum.hdfgroup.org/u/daniel.meier)\
**Post date:** [January 14, 2020, 11:08pm UTC](https://forum.hdfgroup.org/t/hdfql-strange-characters-randomly-from-select-command/6561/5 "2020-01-14T23:08:34Z")

</div>

Thank you! That seems to work for me. Also used StringBuilder, thanks.

---

<div class="post-metadata">

**Author:** ![contact](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/contact/32/1067_2.png) [@contact](https://forum.hdfgroup.org/u/contact)\
**Post date:** [January 15, 2020, 9:09pm UTC](https://forum.hdfgroup.org/t/hdfql-strange-characters-randomly-from-select-command/6561/6 "2020-01-15T21:09:03Z")

</div>

Great to know that it works!
