# Filename in file source from GRC and automatic clear reports?

**URL:** <https://www.ruby-forum.com/t/filename-in-file-source-from-grc-and-automatic-clear-reports/242248>\
**Category:** GNU Radio\
**Created:** [June 9, 2015, 6:09am UTC](https://www.ruby-forum.com/t/filename-in-file-source-from-grc-and-automatic-clear-reports/242248 "2015-06-09T06:09:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [June 9, 2015, 6:09am UTC](https://www.ruby-forum.com/t/filename-in-file-source-from-grc-and-automatic-clear-reports/242248/1 "2015-06-09T06:09:42Z")

</div>

It’s not a critical issue.

1. How could I put filename which contains variables?

After I define a variable `time` with a value of `20150609`. I want to  
use  
a file `/my/file/path/sample20150609` as a file source.

In `file` field (filename) in file source block, how can I refer such a  
variable? I put variable name in the field, but it seems the GRC regards  
it  
as a string literal.

1. Every time before I run the GRC flow graph, I want to clear the  
reports  
(console log).

I think it is possible if I put something in `.grc` file in the home  
directory. But, I have no idea about that `something`.

Regards,  
Jeon.

---

<div class="post-metadata">

**Author:** ![Jeon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e8c25b/32.png) [@Jeon](https://www.ruby-forum.com/u/Jeon)\
**Post date:** [June 9, 2015, 9:14am UTC](https://www.ruby-forum.com/t/filename-in-file-source-from-grc-and-automatic-clear-reports/242248/2 "2015-06-09T09:14:17Z")

</div>

Hi Jeon,

the input fields just take “normal” python, so

“/my/file/path”+ str(time)

should just work; for more complex things, try python’s (quite frankly  
awesome) string formatting language

“/home/marcus/{dir}/{date}-{hour:02d}-{minute:02d}-{seconds:02.6f}.dat”.format(dir="/samples",  
date=20150609,hour=8,minute=59,seconds=25.33212324)

will give you  
/home/marcus//samples/20150609-08-59-25.332123.dat

notice the length of each number and the padding with zero of the hour.

Possibly, GRC tries to figure out whether what you’ve entered into the  
text field is just text (and must be surrounded by " ) or python code,  
and goes wrong.

1. There’s no setting I’d know of that would enable that; the only way I  
can find in the source code is View-\>Clear Reports, which triggers the  
CLEAR\_REPORT GRC Action; if you feel like it, you could add a “clear  
reports on flow graph launch” checkbox there and modify the Action that  
happens when you click on “run” to include conditional clearing of the  
reports.

Greetings,  
Marcus

---

<div class="post-metadata">

**Author:** ![Jeon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e8c25b/32.png) [@Jeon](https://www.ruby-forum.com/u/Jeon)\
**Post date:** [June 9, 2015, 9:45am UTC](https://www.ruby-forum.com/t/filename-in-file-source-from-grc-and-automatic-clear-reports/242248/3 "2015-06-09T09:45:16Z")

</div>

Dear Marcus.

Thanks for your answers.

I’ve tried and seen that `str(var)` appears as it is. And I thought it  
didn’t work. But according to your answer, it is converted to a string  
properly when py file was generated and executed. Is it right?

And for clearing reports, your suggestion is to modify source code of  
GRC  
app itself. I’ll try it later.

Again thank you for your kind answers

Regards,  
Jeon.

2015-06-09 16:13 GMT+09:00 Marcus Müller [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![Jeon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e8c25b/32.png) [@Jeon](https://www.ruby-forum.com/u/Jeon)\
**Post date:** [June 9, 2015, 11:50am UTC](https://www.ruby-forum.com/t/filename-in-file-source-from-grc-and-automatic-clear-reports/242248/4 "2015-06-09T11:50:17Z")

</div>

Hi Jeon,

I think it’s possible GRC looks for " in the field, so maybe  
“” +str(var)  
works?

Best regards,  
Marcus

---

<div class="post-metadata">

**Author:** ![Jeon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e8c25b/32.png) [@Jeon](https://www.ruby-forum.com/u/Jeon)\
**Post date:** [June 9, 2015, 2:06pm UTC](https://www.ruby-forum.com/t/filename-in-file-source-from-grc-and-automatic-clear-reports/242248/5 "2015-06-09T14:06:59Z")

</div>

Hi,

1. In grc, try the import block with: import datetime  
and in the file name put:  
datetime.datetime.now().strftime(“%Y-%m-%d-%H:%M”) or similar depending  
on  
the format that you want. You’ll find a more detailed explanation here:  
[python - How to print a date in a regular format? - Stack Overflow](http://stackoverflow.com/questions/311627/how-to-print-date-in-a-regular-format-in-python)

Cheers,  
Murray

2015-06-09 10:30 GMT+01:00 Marcus Müller [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
